Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * epautoconf.c -- endpoint autoconfiguration for usb gadget drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2004 David Brownell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/usb/ch9.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/usb/gadget.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * usb_ep_autoconfig_ss() - choose an endpoint matching the ep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * descriptor and ep companion descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * @gadget: The device to which the endpoint must belong.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * @desc: Endpoint descriptor, with endpoint direction and transfer mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *    initialized.  For periodic transfers, the maximum packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *    size must also be initialized.  This is modified on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *    success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * @ep_comp: Endpoint companion descriptor, with the required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *    number of streams. Will be modified when the chosen EP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *    supports a different number of streams.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * This routine replaces the usb_ep_autoconfig when needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * superspeed enhancments. If such enhancemnets are required,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * the FD should call usb_ep_autoconfig_ss directly and provide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * the additional ep_comp parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * By choosing an endpoint to use with the specified descriptor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * this routine simplifies writing gadget drivers that work with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * multiple USB device controllers.  The endpoint would be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * passed later to usb_ep_enable(), along with some descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * That second descriptor won't always be the same as the first one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * For example, isochronous endpoints can be autoconfigured for high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * bandwidth, and then used in several lower bandwidth altsettings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * Also, high and full speed descriptors will be different.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * Be sure to examine and test the results of autoconfiguration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * on your hardware.  This code may not make the best choices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * about how to use the USB controller, and it can't know all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * the restrictions that may apply. Some combinations of driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * and hardware won't be able to autoconfigure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * On success, this returns an claimed usb_ep, and modifies the endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * descriptor bEndpointAddress.  For bulk endpoints, the wMaxPacket value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * is initialized as if the endpoint were used at full speed and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * the bmAttribute field in the ep companion descriptor is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * updated with the assigned number of streams if it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * different from the original value. To prevent the endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * from being returned by a later autoconfig call, claims it by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * assigning ep->claimed to true.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * On failure, this returns a null endpoint descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) struct usb_ep *usb_ep_autoconfig_ss(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct usb_gadget		*gadget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	struct usb_endpoint_descriptor	*desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	struct usb_ss_ep_comp_descriptor *ep_comp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct usb_ep	*ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	u8 type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (gadget->ops->match_ep) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		ep = gadget->ops->match_ep(gadget, desc, ep_comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		if (ep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			goto found_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/* Second, look at endpoints until an unclaimed one looks usable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	list_for_each_entry (ep, &gadget->ep_list, ep_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			goto found_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/* Fail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) found_ep:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	 * If the protocol driver hasn't yet decided on wMaxPacketSize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	 * and wants to know the maximum possible, provide the info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	if (desc->wMaxPacketSize == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket_limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/* report address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	desc->bEndpointAddress &= USB_DIR_IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	if (isdigit(ep->name[2])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		u8 num = simple_strtoul(&ep->name[2], NULL, 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		desc->bEndpointAddress |= num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	} else if (desc->bEndpointAddress & USB_DIR_IN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		if (++gadget->in_epnum > 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		if (++gadget->out_epnum > 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		desc->bEndpointAddress |= gadget->out_epnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	ep->address = desc->bEndpointAddress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	ep->desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	ep->comp_desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	ep->claimed = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	ep->transfer_type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if (gadget_is_superspeed(gadget) && ep_comp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		case USB_ENDPOINT_XFER_ISOC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			/* mult: bits 1:0 of bmAttributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			ep->mult = (ep_comp->bmAttributes & 0x3) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		case USB_ENDPOINT_XFER_BULK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		case USB_ENDPOINT_XFER_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			ep->maxburst = ep_comp->bMaxBurst + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	} else if (gadget_is_dualspeed(gadget) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		   (type == USB_ENDPOINT_XFER_ISOC ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		    type == USB_ENDPOINT_XFER_INT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		ep->mult = usb_endpoint_maxp_mult(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * usb_ep_autoconfig() - choose an endpoint matching the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * @gadget: The device to which the endpoint must belong.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * @desc: Endpoint descriptor, with endpoint direction and transfer mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  *	initialized.  For periodic transfers, the maximum packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  *	size must also be initialized.  This is modified on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * By choosing an endpoint to use with the specified descriptor, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * routine simplifies writing gadget drivers that work with multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * USB device controllers.  The endpoint would be passed later to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * usb_ep_enable(), along with some descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * That second descriptor won't always be the same as the first one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * For example, isochronous endpoints can be autoconfigured for high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * bandwidth, and then used in several lower bandwidth altsettings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * Also, high and full speed descriptors will be different.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * Be sure to examine and test the results of autoconfiguration on your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * hardware.  This code may not make the best choices about how to use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * USB controller, and it can't know all the restrictions that may apply.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * Some combinations of driver and hardware won't be able to autoconfigure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * On success, this returns an claimed usb_ep, and modifies the endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  * descriptor bEndpointAddress.  For bulk endpoints, the wMaxPacket value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  * is initialized as if the endpoint were used at full speed. Because of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * that the users must consider adjusting the autoconfigured descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * To prevent the endpoint from being returned by a later autoconfig call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * claims it by assigning ep->claimed to true.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * On failure, this returns a null endpoint descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct usb_ep *usb_ep_autoconfig(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct usb_gadget		*gadget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct usb_endpoint_descriptor	*desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	struct usb_ep	*ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	u8		type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	ep = usb_ep_autoconfig_ss(gadget, desc, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	if (!ep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	/* report (variable) full speed bulk maxpacket */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (type == USB_ENDPOINT_XFER_BULK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		int size = ep->maxpacket_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		/* min() doesn't work on bitfields with gcc-3.5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		if (size > 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			size = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		desc->wMaxPacketSize = cpu_to_le16(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	return ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) EXPORT_SYMBOL_GPL(usb_ep_autoconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  * usb_ep_autoconfig_release - releases endpoint and set it to initial state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  * @ep: endpoint which should be released
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  * This function can be used during function bind for endpoints obtained
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  * from usb_ep_autoconfig(). It unclaims endpoint claimed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * usb_ep_autoconfig() to make it available for other functions. Endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * which was released is no longer invalid and shouldn't be used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * context of function which released it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) void usb_ep_autoconfig_release(struct usb_ep *ep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	ep->claimed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	ep->driver_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) EXPORT_SYMBOL_GPL(usb_ep_autoconfig_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  * usb_ep_autoconfig_reset - reset endpoint autoconfig state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  * @gadget: device for which autoconfig state will be reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * Use this for devices where one configuration may need to assign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  * endpoint resources very differently from the next one.  It clears
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * state such as ep->claimed and the record of assigned endpoints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  * used by usb_ep_autoconfig().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	struct usb_ep	*ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	list_for_each_entry (ep, &gadget->ep_list, ep_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		ep->claimed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		ep->driver_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	gadget->in_epnum = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	gadget->out_epnum = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset);