提交 7177aed4 编写于 作者: M Michal Nazarewicz 提交者: Felipe Balbi

usb: gadget: rename usb_gadget_driver::speed to max_speed

This commit renames the “speed” field of the usb_gadget_driver
structure to “max_speed”.  This is so that to make it more
apparent that the field represents the maximum speed gadget
driver can support.

This also make the field look more like fields with the same
name in usb_gadget and usb_composite_driver structures.  All
of those represent the *maximal* speed given entity supports.

After this commit, there are the following fields in various
structures:
* usb_gadget::speed - the current connection speed,
* usb_gadget::max_speed - maximal speed UDC supports,
* usb_gadget_driver::max_speed - maximal speed gadget driver
  supports, and
* usb_composite_driver::max_speed - maximal speed composite
  gadget supports.
Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 d327ab5b
...@@ -1959,7 +1959,7 @@ static int amd5536_start(struct usb_gadget_driver *driver, ...@@ -1959,7 +1959,7 @@ static int amd5536_start(struct usb_gadget_driver *driver,
u32 tmp; u32 tmp;
if (!driver || !bind || !driver->setup if (!driver || !bind || !driver->setup
|| driver->speed < USB_SPEED_HIGH) || driver->max_speed < USB_SPEED_HIGH)
return -EINVAL; return -EINVAL;
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
......
...@@ -1633,7 +1633,7 @@ static int at91_start(struct usb_gadget_driver *driver, ...@@ -1633,7 +1633,7 @@ static int at91_start(struct usb_gadget_driver *driver,
unsigned long flags; unsigned long flags;
if (!driver if (!driver
|| driver->speed < USB_SPEED_FULL || driver->max_speed < USB_SPEED_FULL
|| !bind || !bind
|| !driver->setup) { || !driver->setup) {
DBG("bad parameter.\n"); DBG("bad parameter.\n");
......
...@@ -813,7 +813,7 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr, ...@@ -813,7 +813,7 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr,
n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n", n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n",
(driver->function ? driver->function : "")); (driver->function ? driver->function : ""));
n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n", n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n",
driver->speed); driver->max_speed);
return n; return n;
} }
......
...@@ -1535,9 +1535,9 @@ composite_resume(struct usb_gadget *gadget) ...@@ -1535,9 +1535,9 @@ composite_resume(struct usb_gadget *gadget)
static struct usb_gadget_driver composite_driver = { static struct usb_gadget_driver composite_driver = {
#ifdef CONFIG_USB_GADGET_SUPERSPEED #ifdef CONFIG_USB_GADGET_SUPERSPEED
.speed = USB_SPEED_SUPER, .max_speed = USB_SPEED_SUPER,
#else #else
.speed = USB_SPEED_HIGH, .max_speed = USB_SPEED_HIGH,
#endif #endif
.unbind = composite_unbind, .unbind = composite_unbind,
...@@ -1584,8 +1584,8 @@ int usb_composite_probe(struct usb_composite_driver *driver, ...@@ -1584,8 +1584,8 @@ int usb_composite_probe(struct usb_composite_driver *driver,
driver->iProduct = driver->name; driver->iProduct = driver->name;
composite_driver.function = (char *) driver->name; composite_driver.function = (char *) driver->name;
composite_driver.driver.name = driver->name; composite_driver.driver.name = driver->name;
composite_driver.speed = min((u8)composite_driver.speed, composite_driver.max_speed =
(u8)driver->max_speed); min_t(u8, composite_driver.max_speed, driver->max_speed);
composite = driver; composite = driver;
composite_gadget_bind = bind; composite_gadget_bind = bind;
......
...@@ -404,7 +404,7 @@ static int dbgp_setup(struct usb_gadget *gadget, ...@@ -404,7 +404,7 @@ static int dbgp_setup(struct usb_gadget *gadget,
static struct usb_gadget_driver dbgp_driver = { static struct usb_gadget_driver dbgp_driver = {
.function = "dbgp", .function = "dbgp",
.speed = USB_SPEED_HIGH, .max_speed = USB_SPEED_HIGH,
.unbind = dbgp_unbind, .unbind = dbgp_unbind,
.setup = dbgp_setup, .setup = dbgp_setup,
.disconnect = dbgp_disconnect, .disconnect = dbgp_disconnect,
......
...@@ -823,19 +823,18 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value) ...@@ -823,19 +823,18 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value)
if (value && dum->driver) { if (value && dum->driver) {
if (mod_data.is_super_speed) if (mod_data.is_super_speed)
dum->gadget.speed = dum->driver->speed; dum->gadget.speed = dum->driver->max_speed;
else if (mod_data.is_high_speed) else if (mod_data.is_high_speed)
dum->gadget.speed = min_t(u8, USB_SPEED_HIGH, dum->gadget.speed = min_t(u8, USB_SPEED_HIGH,
dum->driver->speed); dum->driver->max_speed);
else else
dum->gadget.speed = USB_SPEED_FULL; dum->gadget.speed = USB_SPEED_FULL;
dummy_udc_udpate_ep0(dum); dummy_udc_udpate_ep0(dum);
if (dum->gadget.speed < dum->driver->speed) if (dum->gadget.speed < dum->driver->max_speed)
dev_dbg(udc_dev(dum), "This device can perform faster" dev_dbg(udc_dev(dum), "This device can perform faster"
" if you connect it to a %s port...\n", " if you connect it to a %s port...\n",
(dum->driver->speed == USB_SPEED_SUPER ? usb_speed_string(dum->driver->max_speed));
"SuperSpeed" : "HighSpeed"));
} }
dum_hcd = gadget_to_dummy_hcd(_gadget); dum_hcd = gadget_to_dummy_hcd(_gadget);
...@@ -898,7 +897,7 @@ static int dummy_udc_start(struct usb_gadget *g, ...@@ -898,7 +897,7 @@ static int dummy_udc_start(struct usb_gadget *g,
struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g);
struct dummy *dum = dum_hcd->dum; struct dummy *dum = dum_hcd->dum;
if (driver->speed == USB_SPEED_UNKNOWN) if (driver->max_speed == USB_SPEED_UNKNOWN)
return -EINVAL; return -EINVAL;
/* /*
......
...@@ -3604,7 +3604,7 @@ static void fsg_resume(struct usb_gadget *gadget) ...@@ -3604,7 +3604,7 @@ static void fsg_resume(struct usb_gadget *gadget)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static struct usb_gadget_driver fsg_driver = { static struct usb_gadget_driver fsg_driver = {
.speed = USB_SPEED_SUPER, .max_speed = USB_SPEED_SUPER,
.function = (char *) fsg_string_product, .function = (char *) fsg_string_product,
.unbind = fsg_unbind, .unbind = fsg_unbind,
.disconnect = fsg_disconnect, .disconnect = fsg_disconnect,
......
...@@ -2336,7 +2336,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver, ...@@ -2336,7 +2336,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver,
if (!udc_controller) if (!udc_controller)
return -ENODEV; return -ENODEV;
if (!driver || driver->speed < USB_SPEED_FULL if (!driver || driver->max_speed < USB_SPEED_FULL
|| !bind || !driver->disconnect || !driver->setup) || !bind || !driver->disconnect || !driver->setup)
return -EINVAL; return -EINVAL;
...@@ -2350,7 +2350,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver, ...@@ -2350,7 +2350,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver,
/* hook up the driver */ /* hook up the driver */
udc_controller->driver = driver; udc_controller->driver = driver;
udc_controller->gadget.dev.driver = &driver->driver; udc_controller->gadget.dev.driver = &driver->driver;
udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed); udc_controller->gadget.speed = driver->max_speed;
spin_unlock_irqrestore(&udc_controller->lock, flags); spin_unlock_irqrestore(&udc_controller->lock, flags);
retval = bind(&udc_controller->gadget); retval = bind(&udc_controller->gadget);
......
...@@ -1934,7 +1934,7 @@ static int fsl_start(struct usb_gadget_driver *driver, ...@@ -1934,7 +1934,7 @@ static int fsl_start(struct usb_gadget_driver *driver,
if (!udc_controller) if (!udc_controller)
return -ENODEV; return -ENODEV;
if (!driver || driver->speed < USB_SPEED_FULL if (!driver || driver->max_speed < USB_SPEED_FULL
|| !bind || !driver->disconnect || !driver->setup) || !bind || !driver->disconnect || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1317,7 +1317,7 @@ static int fusb300_udc_start(struct usb_gadget_driver *driver, ...@@ -1317,7 +1317,7 @@ static int fusb300_udc_start(struct usb_gadget_driver *driver,
int retval; int retval;
if (!driver if (!driver
|| driver->speed < USB_SPEED_FULL || driver->max_speed < USB_SPEED_FULL
|| !bind || !bind
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1357,7 +1357,7 @@ static int goku_start(struct usb_gadget_driver *driver, ...@@ -1357,7 +1357,7 @@ static int goku_start(struct usb_gadget_driver *driver,
int retval; int retval;
if (!driver if (!driver
|| driver->speed < USB_SPEED_FULL || driver->max_speed < USB_SPEED_FULL
|| !bind || !bind
|| !driver->disconnect || !driver->disconnect
|| !driver->setup) || !driver->setup)
......
...@@ -1336,7 +1336,7 @@ static int imx_udc_start(struct usb_gadget_driver *driver, ...@@ -1336,7 +1336,7 @@ static int imx_udc_start(struct usb_gadget_driver *driver,
int retval; int retval;
if (!driver if (!driver
|| driver->speed < USB_SPEED_FULL || driver->max_speed < USB_SPEED_FULL
|| !bind || !bind
|| !driver->disconnect || !driver->disconnect
|| !driver->setup) || !driver->setup)
......
...@@ -1766,9 +1766,9 @@ gadgetfs_suspend (struct usb_gadget *gadget) ...@@ -1766,9 +1766,9 @@ gadgetfs_suspend (struct usb_gadget *gadget)
static struct usb_gadget_driver gadgetfs_driver = { static struct usb_gadget_driver gadgetfs_driver = {
#ifdef CONFIG_USB_GADGET_DUALSPEED #ifdef CONFIG_USB_GADGET_DUALSPEED
.speed = USB_SPEED_HIGH, .max_speed = USB_SPEED_HIGH,
#else #else
.speed = USB_SPEED_FULL, .max_speed = USB_SPEED_FULL,
#endif #endif
.function = (char *) driver_desc, .function = (char *) driver_desc,
.unbind = gadgetfs_unbind, .unbind = gadgetfs_unbind,
...@@ -1792,7 +1792,7 @@ static int gadgetfs_probe (struct usb_gadget *gadget) ...@@ -1792,7 +1792,7 @@ static int gadgetfs_probe (struct usb_gadget *gadget)
} }
static struct usb_gadget_driver probe_driver = { static struct usb_gadget_driver probe_driver = {
.speed = USB_SPEED_HIGH, .max_speed = USB_SPEED_HIGH,
.unbind = gadgetfs_nop, .unbind = gadgetfs_nop,
.setup = (void *)gadgetfs_nop, .setup = (void *)gadgetfs_nop,
.disconnect = gadgetfs_nop, .disconnect = gadgetfs_nop,
......
...@@ -1472,7 +1472,7 @@ static int m66592_start(struct usb_gadget_driver *driver, ...@@ -1472,7 +1472,7 @@ static int m66592_start(struct usb_gadget_driver *driver,
int retval; int retval;
if (!driver if (!driver
|| driver->speed < USB_SPEED_HIGH || driver->max_speed < USB_SPEED_HIGH
|| !bind || !bind
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1459,7 +1459,7 @@ static int net2272_start(struct usb_gadget *_gadget, ...@@ -1459,7 +1459,7 @@ static int net2272_start(struct usb_gadget *_gadget,
unsigned i; unsigned i;
if (!driver || !driver->unbind || !driver->setup || if (!driver || !driver->unbind || !driver->setup ||
driver->speed != USB_SPEED_HIGH) driver->max_speed != USB_SPEED_HIGH)
return -EINVAL; return -EINVAL;
dev = container_of(_gadget, struct net2272, gadget); dev = container_of(_gadget, struct net2272, gadget);
......
...@@ -1881,7 +1881,7 @@ static int net2280_start(struct usb_gadget *_gadget, ...@@ -1881,7 +1881,7 @@ static int net2280_start(struct usb_gadget *_gadget,
* (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE) * (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE)
* "must not be used in normal operation" * "must not be used in normal operation"
*/ */
if (!driver || driver->speed < USB_SPEED_HIGH if (!driver || driver->max_speed < USB_SPEED_HIGH
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -2110,7 +2110,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, ...@@ -2110,7 +2110,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
return -ENODEV; return -ENODEV;
if (!driver if (!driver
// FIXME if otg, check: driver->is_otg // FIXME if otg, check: driver->is_otg
|| driver->speed < USB_SPEED_FULL || driver->max_speed < USB_SPEED_FULL
|| !bind || !driver->setup) || !bind || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -2693,7 +2693,7 @@ static int pch_udc_start(struct usb_gadget_driver *driver, ...@@ -2693,7 +2693,7 @@ static int pch_udc_start(struct usb_gadget_driver *driver,
struct pch_udc_dev *dev = pch_udc; struct pch_udc_dev *dev = pch_udc;
int retval; int retval;
if (!driver || (driver->speed == USB_SPEED_UNKNOWN) || !bind || if (!driver || (driver->max_speed == USB_SPEED_UNKNOWN) || !bind ||
!driver->setup || !driver->unbind || !driver->disconnect) { !driver->setup || !driver->unbind || !driver->disconnect) {
dev_err(&dev->pdev->dev, dev_err(&dev->pdev->dev,
"%s: invalid driver parameter\n", __func__); "%s: invalid driver parameter\n", __func__);
......
...@@ -1535,7 +1535,7 @@ printer_bind(struct usb_gadget *gadget) ...@@ -1535,7 +1535,7 @@ printer_bind(struct usb_gadget *gadget)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static struct usb_gadget_driver printer_driver = { static struct usb_gadget_driver printer_driver = {
.speed = DEVSPEED, .max_speed = DEVSPEED,
.function = (char *) driver_desc, .function = (char *) driver_desc,
.unbind = printer_unbind, .unbind = printer_unbind,
......
...@@ -1264,7 +1264,7 @@ static int pxa25x_start(struct usb_gadget_driver *driver, ...@@ -1264,7 +1264,7 @@ static int pxa25x_start(struct usb_gadget_driver *driver,
int retval; int retval;
if (!driver if (!driver
|| driver->speed < USB_SPEED_FULL || driver->max_speed < USB_SPEED_FULL
|| !bind || !bind
|| !driver->disconnect || !driver->disconnect
|| !driver->setup) || !driver->setup)
......
...@@ -1807,7 +1807,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, ...@@ -1807,7 +1807,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
struct pxa_udc *udc = the_controller; struct pxa_udc *udc = the_controller;
int retval; int retval;
if (!driver || driver->speed < USB_SPEED_FULL || !bind if (!driver || driver->max_speed < USB_SPEED_FULL || !bind
|| !driver->disconnect || !driver->setup) || !driver->disconnect || !driver->setup)
return -EINVAL; return -EINVAL;
if (!udc) if (!udc)
......
...@@ -1746,7 +1746,7 @@ static int r8a66597_start(struct usb_gadget *gadget, ...@@ -1746,7 +1746,7 @@ static int r8a66597_start(struct usb_gadget *gadget,
struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget); struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
if (!driver if (!driver
|| driver->speed < USB_SPEED_HIGH || driver->max_speed < USB_SPEED_HIGH
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
if (!r8a66597) if (!r8a66597)
......
...@@ -2586,7 +2586,7 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver, ...@@ -2586,7 +2586,7 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver,
return -EINVAL; return -EINVAL;
} }
if (driver->speed < USB_SPEED_FULL) if (driver->max_speed < USB_SPEED_FULL)
dev_err(hsotg->dev, "%s: bad speed\n", __func__); dev_err(hsotg->dev, "%s: bad speed\n", __func__);
if (!bind || !driver->setup) { if (!bind || !driver->setup) {
......
...@@ -1142,7 +1142,7 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, ...@@ -1142,7 +1142,7 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver,
int ret; int ret;
if (!driver if (!driver
|| driver->speed < USB_SPEED_FULL || driver->max_speed < USB_SPEED_FULL
|| !bind || !bind
|| !driver->unbind || !driver->disconnect || !driver->setup) || !driver->unbind || !driver->disconnect || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1683,9 +1683,9 @@ static int s3c2410_udc_start(struct usb_gadget_driver *driver, ...@@ -1683,9 +1683,9 @@ static int s3c2410_udc_start(struct usb_gadget_driver *driver,
if (udc->driver) if (udc->driver)
return -EBUSY; return -EBUSY;
if (!bind || !driver->setup || driver->speed < USB_SPEED_FULL) { if (!bind || !driver->setup || driver->max_speed < USB_SPEED_FULL) {
printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n",
bind, driver->setup, driver->speed); bind, driver->setup, driver->max_speed);
return -EINVAL; return -EINVAL;
} }
#if defined(MODULE) #if defined(MODULE)
......
...@@ -1903,7 +1903,7 @@ static int musb_gadget_start(struct usb_gadget *g, ...@@ -1903,7 +1903,7 @@ static int musb_gadget_start(struct usb_gadget *g,
unsigned long flags; unsigned long flags;
int retval = -EINVAL; int retval = -EINVAL;
if (driver->speed < USB_SPEED_HIGH) if (driver->max_speed < USB_SPEED_HIGH)
goto err0; goto err0;
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
......
...@@ -751,7 +751,7 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget, ...@@ -751,7 +751,7 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget,
if (!driver || if (!driver ||
!driver->setup || !driver->setup ||
driver->speed < USB_SPEED_FULL) driver->max_speed < USB_SPEED_FULL)
return -EINVAL; return -EINVAL;
/* first hook up the driver ... */ /* first hook up the driver ... */
......
...@@ -760,7 +760,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) ...@@ -760,7 +760,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
/** /**
* struct usb_gadget_driver - driver for usb 'slave' devices * struct usb_gadget_driver - driver for usb 'slave' devices
* @function: String describing the gadget's function * @function: String describing the gadget's function
* @speed: Highest speed the driver handles. * @max_speed: Highest speed the driver handles.
* @setup: Invoked for ep0 control requests that aren't handled by * @setup: Invoked for ep0 control requests that aren't handled by
* the hardware level driver. Most calls must be handled by * the hardware level driver. Most calls must be handled by
* the gadget driver, including descriptor and configuration * the gadget driver, including descriptor and configuration
...@@ -824,7 +824,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) ...@@ -824,7 +824,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
*/ */
struct usb_gadget_driver { struct usb_gadget_driver {
char *function; char *function;
enum usb_device_speed speed; enum usb_device_speed max_speed;
void (*unbind)(struct usb_gadget *); void (*unbind)(struct usb_gadget *);
int (*setup)(struct usb_gadget *, int (*setup)(struct usb_gadget *,
const struct usb_ctrlrequest *); const struct usb_ctrlrequest *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册