提交 e87bb711 编写于 作者: S Sebastian Andrzej Siewior 提交者: Felipe Balbi

usb: gadget: move global vars from epautoconf into struct usb_gadget

epautoconf has two global variables which count the endpoint number of
last assigned endpoint.
This patch removes the global variable and keeps it as per (UDC) gadget.
While here, the ifdef is removed and now the in and outpoint are
enumerated unconditionally. The dwc3 for instance supports 32 endpoints
in total.
Acked-by: NMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 0ba16dea
...@@ -22,17 +22,6 @@ ...@@ -22,17 +22,6 @@
#include "gadget_chips.h" #include "gadget_chips.h"
/* we must assign addresses for configurable endpoints (like net2280) */
static unsigned epnum;
// #define MANY_ENDPOINTS
#ifdef MANY_ENDPOINTS
/* more than 15 configurable endpoints */
static unsigned in_epnum;
#endif
/* /*
* This should work with endpoints from controller drivers sharing the * This should work with endpoints from controller drivers sharing the
* same endpoint naming convention. By example: * same endpoint naming convention. By example:
...@@ -176,16 +165,14 @@ ep_matches ( ...@@ -176,16 +165,14 @@ ep_matches (
if (isdigit (ep->name [2])) { if (isdigit (ep->name [2])) {
u8 num = simple_strtoul (&ep->name [2], NULL, 10); u8 num = simple_strtoul (&ep->name [2], NULL, 10);
desc->bEndpointAddress |= num; desc->bEndpointAddress |= num;
#ifdef MANY_ENDPOINTS
} else if (desc->bEndpointAddress & USB_DIR_IN) { } else if (desc->bEndpointAddress & USB_DIR_IN) {
if (++in_epnum > 15) if (++gadget->in_epnum > 15)
return 0; return 0;
desc->bEndpointAddress = USB_DIR_IN | in_epnum; desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum;
#endif
} else { } else {
if (++epnum > 15) if (++gadget->out_epnum > 15)
return 0; return 0;
desc->bEndpointAddress |= epnum; desc->bEndpointAddress |= gadget->out_epnum;
} }
/* report (variable) full speed bulk maxpacket */ /* report (variable) full speed bulk maxpacket */
...@@ -385,9 +372,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) ...@@ -385,9 +372,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
list_for_each_entry (ep, &gadget->ep_list, ep_list) { list_for_each_entry (ep, &gadget->ep_list, ep_list) {
ep->driver_data = NULL; ep->driver_data = NULL;
} }
#ifdef MANY_ENDPOINTS gadget->in_epnum = 0;
in_epnum = 0; gadget->out_epnum = 0;
#endif
epnum = 0;
} }
...@@ -503,6 +503,8 @@ struct usb_gadget_ops { ...@@ -503,6 +503,8 @@ struct usb_gadget_ops {
* @name: Identifies the controller hardware type. Used in diagnostics * @name: Identifies the controller hardware type. Used in diagnostics
* and sometimes configuration. * and sometimes configuration.
* @dev: Driver model state for this abstract device. * @dev: Driver model state for this abstract device.
* @out_epnum: last used out ep number
* @in_epnum: last used in ep number
* *
* Gadgets have a mostly-portable "gadget driver" implementing device * Gadgets have a mostly-portable "gadget driver" implementing device
* functions, handling all usb configurations and interfaces. Gadget * functions, handling all usb configurations and interfaces. Gadget
...@@ -537,6 +539,8 @@ struct usb_gadget { ...@@ -537,6 +539,8 @@ struct usb_gadget {
unsigned a_alt_hnp_support:1; unsigned a_alt_hnp_support:1;
const char *name; const char *name;
struct device dev; struct device dev;
unsigned out_epnum;
unsigned in_epnum;
}; };
static inline void set_gadget_data(struct usb_gadget *gadget, void *data) static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册