forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/usb/gadget/epautoconf.c
....@@ -67,9 +67,6 @@
6767 )
6868 {
6969 struct usb_ep *ep;
70
- u8 type;
71
-
72
- type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
7370
7471 if (gadget->ops->match_ep) {
7572 ep = gadget->ops->match_ep(gadget, desc, ep_comp);
....@@ -109,41 +106,10 @@
109106 desc->bEndpointAddress |= gadget->out_epnum;
110107 }
111108
112
- /* report (variable) full speed bulk maxpacket */
113
- if ((type == USB_ENDPOINT_XFER_BULK) && !ep_comp) {
114
- int size = ep->maxpacket_limit;
115
-
116
- /* min() doesn't work on bitfields with gcc-3.5 */
117
- if (size > 64)
118
- size = 64;
119
- desc->wMaxPacketSize = cpu_to_le16(size);
120
- }
121
-
122109 ep->address = desc->bEndpointAddress;
123110 ep->desc = NULL;
124111 ep->comp_desc = NULL;
125112 ep->claimed = true;
126
-#ifdef CONFIG_ARCH_ROCKCHIP
127
- ep->transfer_type = type;
128
- if (gadget_is_superspeed(gadget) && ep_comp) {
129
- switch (type) {
130
- case USB_ENDPOINT_XFER_ISOC:
131
- /* mult: bits 1:0 of bmAttributes */
132
- ep->mult = (ep_comp->bmAttributes & 0x3) + 1;
133
- /* fall through */
134
- case USB_ENDPOINT_XFER_BULK:
135
- case USB_ENDPOINT_XFER_INT:
136
- ep->maxburst = ep_comp->bMaxBurst + 1;
137
- break;
138
- default:
139
- break;
140
- }
141
- } else if (gadget_is_dualspeed(gadget) &&
142
- (type == USB_ENDPOINT_XFER_ISOC ||
143
- type == USB_ENDPOINT_XFER_INT)) {
144
- ep->mult = usb_endpoint_maxp_mult(desc);
145
- }
146
-#endif
147113 return ep;
148114 }
149115 EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss);
....@@ -173,9 +139,10 @@
173139 *
174140 * On success, this returns an claimed usb_ep, and modifies the endpoint
175141 * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value
176
- * is initialized as if the endpoint were used at full speed. To prevent
177
- * the endpoint from being returned by a later autoconfig call, claims it
178
- * by assigning ep->claimed to true.
142
+ * is initialized as if the endpoint were used at full speed. Because of
143
+ * that the users must consider adjusting the autoconfigured descriptor.
144
+ * To prevent the endpoint from being returned by a later autoconfig call,
145
+ * claims it by assigning ep->claimed to true.
179146 *
180147 * On failure, this returns a null endpoint descriptor.
181148 */
....@@ -184,7 +151,26 @@
184151 struct usb_endpoint_descriptor *desc
185152 )
186153 {
187
- return usb_ep_autoconfig_ss(gadget, desc, NULL);
154
+ struct usb_ep *ep;
155
+ u8 type;
156
+
157
+ ep = usb_ep_autoconfig_ss(gadget, desc, NULL);
158
+ if (!ep)
159
+ return NULL;
160
+
161
+ type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
162
+
163
+ /* report (variable) full speed bulk maxpacket */
164
+ if (type == USB_ENDPOINT_XFER_BULK) {
165
+ int size = ep->maxpacket_limit;
166
+
167
+ /* min() doesn't work on bitfields with gcc-3.5 */
168
+ if (size > 64)
169
+ size = 64;
170
+ desc->wMaxPacketSize = cpu_to_le16(size);
171
+ }
172
+
173
+ return ep;
188174 }
189175 EXPORT_SYMBOL_GPL(usb_ep_autoconfig);
190176
....@@ -226,46 +212,3 @@
226212 gadget->out_epnum = 0;
227213 }
228214 EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset);
229
-
230
-/**
231
- * usb_ep_autoconfig_by_name - Used to pick the endpoint by name. eg gsi-epin1
232
- * @gadget: The device to which the endpoint must belong.
233
- * @desc: Endpoint descriptor, with endpoint direction and transfer mode
234
- * initialized.
235
- * @ep_name: EP name that is to be searched.
236
- *
237
- */
238
-struct usb_ep *usb_ep_autoconfig_by_name(
239
- struct usb_gadget *gadget,
240
- struct usb_endpoint_descriptor *desc,
241
- const char *ep_name
242
-)
243
-{
244
- struct usb_ep *ep;
245
- bool ep_found = false;
246
-
247
- if (!ep_name || !strlen(ep_name))
248
- goto err;
249
-
250
- list_for_each_entry(ep, &gadget->ep_list, ep_list)
251
- if (strncmp(ep->name, ep_name, strlen(ep_name)) == 0 &&
252
- !ep->driver_data) {
253
- ep_found = true;
254
- break;
255
- }
256
-
257
- if (ep_found) {
258
- desc->bEndpointAddress &= USB_DIR_IN;
259
- desc->bEndpointAddress |= ep->ep_num;
260
- ep->address = desc->bEndpointAddress;
261
- pr_debug("Allocating ep address:%x\n", ep->address);
262
- ep->desc = NULL;
263
- ep->comp_desc = NULL;
264
- return ep;
265
- }
266
-
267
-err:
268
- pr_err("%s:error finding ep %s\n", __func__, ep_name);
269
- return NULL;
270
-}
271
-EXPORT_SYMBOL_GPL(usb_ep_autoconfig_by_name);