Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: move non-super speed code out of usb_ep_autoconfig_ss()

The moved code refers to non-super speed endpoints only. This patch also
makes the comment stress the fact, that autoconfigured descriptor might
need some adjustments.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Andrzej Pietrasiewicz and committed by
Felipe Balbi
dffe2d7f 44a9d1b9

+24 -17
+24 -17
drivers/usb/gadget/epautoconf.c
··· 67 67 ) 68 68 { 69 69 struct usb_ep *ep; 70 - u8 type; 71 - 72 - type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 73 70 74 71 if (gadget->ops->match_ep) { 75 72 ep = gadget->ops->match_ep(gadget, desc, ep_comp); ··· 106 109 desc->bEndpointAddress |= gadget->out_epnum; 107 110 } 108 111 109 - /* report (variable) full speed bulk maxpacket */ 110 - if ((type == USB_ENDPOINT_XFER_BULK) && !ep_comp) { 111 - int size = ep->maxpacket_limit; 112 - 113 - /* min() doesn't work on bitfields with gcc-3.5 */ 114 - if (size > 64) 115 - size = 64; 116 - desc->wMaxPacketSize = cpu_to_le16(size); 117 - } 118 - 119 112 ep->address = desc->bEndpointAddress; 120 113 ep->desc = NULL; 121 114 ep->comp_desc = NULL; ··· 139 152 * 140 153 * On success, this returns an claimed usb_ep, and modifies the endpoint 141 154 * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value 142 - * is initialized as if the endpoint were used at full speed. To prevent 143 - * the endpoint from being returned by a later autoconfig call, claims it 144 - * by assigning ep->claimed to true. 155 + * is initialized as if the endpoint were used at full speed. Because of 156 + * that the users must consider adjusting the autoconfigured descriptor. 157 + * To prevent the endpoint from being returned by a later autoconfig call, 158 + * claims it by assigning ep->claimed to true. 145 159 * 146 160 * On failure, this returns a null endpoint descriptor. 147 161 */ ··· 151 163 struct usb_endpoint_descriptor *desc 152 164 ) 153 165 { 154 - return usb_ep_autoconfig_ss(gadget, desc, NULL); 166 + struct usb_ep *ep; 167 + u8 type; 168 + 169 + ep = usb_ep_autoconfig_ss(gadget, desc, NULL); 170 + if (!ep) 171 + return NULL; 172 + 173 + type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 174 + 175 + /* report (variable) full speed bulk maxpacket */ 176 + if (type == USB_ENDPOINT_XFER_BULK) { 177 + int size = ep->maxpacket_limit; 178 + 179 + /* min() doesn't work on bitfields with gcc-3.5 */ 180 + if (size > 64) 181 + size = 64; 182 + desc->wMaxPacketSize = cpu_to_le16(size); 183 + } 184 + 185 + return ep; 155 186 } 156 187 EXPORT_SYMBOL_GPL(usb_ep_autoconfig); 157 188