aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/gadget/epautoconf.c27
-rw-r--r--include/linux/usb/gadget.h4
2 files changed, 10 insertions, 21 deletions
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 51f3d42f5a64..d5a905dbed00 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,17 +22,6 @@
22 22
23#include "gadget_chips.h" 23#include "gadget_chips.h"
24 24
25
26/* we must assign addresses for configurable endpoints (like net2280) */
27static unsigned epnum;
28
29// #define MANY_ENDPOINTS
30#ifdef MANY_ENDPOINTS
31/* more than 15 configurable endpoints */
32static unsigned in_epnum;
33#endif
34
35
36/* 25/*
37 * This should work with endpoints from controller drivers sharing the 26 * This should work with endpoints from controller drivers sharing the
38 * same endpoint naming convention. By example: 27 * same endpoint naming convention. By example:
@@ -176,16 +165,14 @@ ep_matches (
176 if (isdigit (ep->name [2])) { 165 if (isdigit (ep->name [2])) {
177 u8 num = simple_strtoul (&ep->name [2], NULL, 10); 166 u8 num = simple_strtoul (&ep->name [2], NULL, 10);
178 desc->bEndpointAddress |= num; 167 desc->bEndpointAddress |= num;
179#ifdef MANY_ENDPOINTS
180 } else if (desc->bEndpointAddress & USB_DIR_IN) { 168 } else if (desc->bEndpointAddress & USB_DIR_IN) {
181 if (++in_epnum > 15) 169 if (++gadget->in_epnum > 15)
182 return 0; 170 return 0;
183 desc->bEndpointAddress = USB_DIR_IN | in_epnum; 171 desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum;
184#endif
185 } else { 172 } else {
186 if (++epnum > 15) 173 if (++gadget->out_epnum > 15)
187 return 0; 174 return 0;
188 desc->bEndpointAddress |= epnum; 175 desc->bEndpointAddress |= gadget->out_epnum;
189 } 176 }
190 177
191 /* report (variable) full speed bulk maxpacket */ 178 /* report (variable) full speed bulk maxpacket */
@@ -385,9 +372,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
385 list_for_each_entry (ep, &gadget->ep_list, ep_list) { 372 list_for_each_entry (ep, &gadget->ep_list, ep_list) {
386 ep->driver_data = NULL; 373 ep->driver_data = NULL;
387 } 374 }
388#ifdef MANY_ENDPOINTS 375 gadget->in_epnum = 0;
389 in_epnum = 0; 376 gadget->out_epnum = 0;
390#endif
391 epnum = 0;
392} 377}
393 378
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 822c1b88f95a..5b6e50888248 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -503,6 +503,8 @@ struct usb_gadget_ops {
503 * @name: Identifies the controller hardware type. Used in diagnostics 503 * @name: Identifies the controller hardware type. Used in diagnostics
504 * and sometimes configuration. 504 * and sometimes configuration.
505 * @dev: Driver model state for this abstract device. 505 * @dev: Driver model state for this abstract device.
506 * @out_epnum: last used out ep number
507 * @in_epnum: last used in ep number
506 * 508 *
507 * Gadgets have a mostly-portable "gadget driver" implementing device 509 * Gadgets have a mostly-portable "gadget driver" implementing device
508 * functions, handling all usb configurations and interfaces. Gadget 510 * functions, handling all usb configurations and interfaces. Gadget
@@ -537,6 +539,8 @@ struct usb_gadget {
537 unsigned a_alt_hnp_support:1; 539 unsigned a_alt_hnp_support:1;
538 const char *name; 540 const char *name;
539 struct device dev; 541 struct device dev;
542 unsigned out_epnum;
543 unsigned in_epnum;
540}; 544};
541 545
542static inline void set_gadget_data(struct usb_gadget *gadget, void *data) 546static inline void set_gadget_data(struct usb_gadget *gadget, void *data)