]> git.baikalelectronics.ru Git - kernel.git/commitdiff
usb gadget: don't save bind callback in struct usb_gadget_driver
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 12 Aug 2010 15:43:53 +0000 (17:43 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 22 Oct 2010 17:21:25 +0000 (10:21 -0700)
To accomplish this the function to register a gadget driver takes the bind
function as a second argument.  To make things clearer rename the function
to resemble platform_driver_probe.

This fixes many section mismatches like

WARNING: drivers/usb/gadget/g_printer.o(.data+0xc): Section mismatch in
reference from the variable printer_driver to the function
.init.text:printer_bind()
The variable printer_driver references
the function __init printer_bind()

All callers are fixed.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[m.nazarewicz@samsung.com: added dbgp]
Signed-off-by: Michał Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27 files changed:
drivers/usb/gadget/amd5536udc.c
drivers/usb/gadget/at91_udc.c
drivers/usb/gadget/atmel_usba_udc.c
drivers/usb/gadget/ci13xxx_udc.c
drivers/usb/gadget/composite.c
drivers/usb/gadget/dbgp.c
drivers/usb/gadget/dummy_hcd.c
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/fsl_qe_udc.c
drivers/usb/gadget/fsl_udc_core.c
drivers/usb/gadget/gmidi.c
drivers/usb/gadget/goku_udc.c
drivers/usb/gadget/imx_udc.c
drivers/usb/gadget/inode.c
drivers/usb/gadget/langwell_udc.c
drivers/usb/gadget/lh7a40x_udc.c
drivers/usb/gadget/m66592-udc.c
drivers/usb/gadget/net2280.c
drivers/usb/gadget/omap_udc.c
drivers/usb/gadget/printer.c
drivers/usb/gadget/pxa25x_udc.c
drivers/usb/gadget/pxa27x_udc.c
drivers/usb/gadget/r8a66597-udc.c
drivers/usb/gadget/s3c-hsotg.c
drivers/usb/gadget/s3c2410_udc.c
drivers/usb/musb/musb_gadget.c
include/linux/usb/gadget.h

index 731150d4b1d9d0e646e34ca03f7cbaa0ac85e398..fadebfd53b479059d44ea3433f9f81bed758c0e3 100644 (file)
@@ -1954,13 +1954,14 @@ static int setup_ep0(struct udc *dev)
 }
 
 /* Called by gadget driver to register itself */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct udc              *dev = udc;
        int                     retval;
        u32 tmp;
 
-       if (!driver || !driver->bind || !driver->setup
+       if (!driver || !bind || !driver->setup
                        || driver->speed != USB_SPEED_HIGH)
                return -EINVAL;
        if (!dev)
@@ -1972,7 +1973,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        dev->driver = driver;
        dev->gadget.dev.driver = &driver->driver;
 
-       retval = driver->bind(&dev->gadget);
+       retval = bind(&dev->gadget);
 
        /* Some gadget drivers use both ep0 directions.
         * NOTE: to gadget driver, ep0 is just one endpoint...
@@ -2000,7 +2001,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        return 0;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 /* shutdown requests and disconnect from gadget */
 static void
index 93ead19507b632c20095980fd5b0350d6407d23d..387e503b9d14a1dc9fac7627bcbbf6f17d8c3637 100644 (file)
@@ -1628,7 +1628,8 @@ static void at91_vbus_timer(unsigned long data)
                schedule_work(&udc->vbus_timer_work);
 }
 
-int usb_gadget_register_driver (struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct at91_udc *udc = &controller;
        int             retval;
@@ -1636,7 +1637,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
 
        if (!driver
                        || driver->speed < USB_SPEED_FULL
-                       || !driver->bind
+                       || !bind
                        || !driver->setup) {
                DBG("bad parameter.\n");
                return -EINVAL;
@@ -1653,9 +1654,9 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
        udc->enabled = 1;
        udc->selfpowered = 1;
 
-       retval = driver->bind(&udc->gadget);
+       retval = bind(&udc->gadget);
        if (retval) {
-               DBG("driver->bind() returned %d\n", retval);
+               DBG("bind() returned %d\n", retval);
                udc->driver = NULL;
                udc->gadget.dev.driver = NULL;
                dev_set_drvdata(&udc->gadget.dev, NULL);
@@ -1671,7 +1672,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
        DBG("bound to %s\n", driver->driver.name);
        return 0;
 }
-EXPORT_SYMBOL (usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
 {
index d623c7bda1f610741dce00ee3ab0216cccc19303..e4810c6a0b1f935961f33f0fedaff60b337390ac 100644 (file)
@@ -1789,7 +1789,8 @@ out:
        return IRQ_HANDLED;
 }
 
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct usba_udc *udc = &the_udc;
        unsigned long flags;
@@ -1812,7 +1813,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        clk_enable(udc->pclk);
        clk_enable(udc->hclk);
 
-       ret = driver->bind(&udc->gadget);
+       ret = bind(&udc->gadget);
        if (ret) {
                DBG(DBG_ERR, "Could not bind to driver %s: error %d\n",
                        driver->driver.name, ret);
@@ -1841,7 +1842,7 @@ err_driver_bind:
        udc->gadget.dev.driver = NULL;
        return ret;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 {
index 699695128e33de185f743afa8f26ed51f38f9295..98b36fc88c77d298bf4f8efb4c9dc2f773f1931a 100644 (file)
@@ -2340,12 +2340,15 @@ static const struct usb_ep_ops usb_ep_ops = {
 static const struct usb_gadget_ops usb_gadget_ops;
 
 /**
- * usb_gadget_register_driver: register a gadget driver
+ * usb_gadget_probe_driver: register a gadget driver
+ * @driver: the driver being registered
+ * @bind: the driver's bind callback
  *
- * Check usb_gadget_register_driver() at "usb_gadget.h" for details
- * Interrupts are enabled here
+ * Check usb_gadget_probe_driver() at <linux/usb/gadget.h> for details.
+ * Interrupts are enabled here.
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct ci13xxx *udc = _udc;
        unsigned long i, k, flags;
@@ -2354,7 +2357,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        trace("%p", driver);
 
        if (driver             == NULL ||
-           driver->bind       == NULL ||
+           bind               == NULL ||
            driver->unbind     == NULL ||
            driver->setup      == NULL ||
            driver->disconnect == NULL ||
@@ -2430,7 +2433,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        udc->gadget.dev.driver = &driver->driver;
 
        spin_unlock_irqrestore(udc->lock, flags);
-       retval = driver->bind(&udc->gadget);                /* MAY SLEEP */
+       retval = bind(&udc->gadget);                /* MAY SLEEP */
        spin_lock_irqsave(udc->lock, flags);
 
        if (retval) {
@@ -2447,7 +2450,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                usb_gadget_unregister_driver(driver);
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 /**
  * usb_gadget_unregister_driver: unregister a gadget driver
@@ -2462,7 +2465,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
        trace("%p", driver);
 
        if (driver             == NULL ||
-           driver->bind       == NULL ||
            driver->unbind     == NULL ||
            driver->setup      == NULL ||
            driver->disconnect == NULL ||
index 717de39627c782e23eef1fd203d2fafada8dc7ab..a3009bf0122960e1d88479a4025e6fbba49f08fb 100644 (file)
@@ -1213,7 +1213,6 @@ composite_resume(struct usb_gadget *gadget)
 static struct usb_gadget_driver composite_driver = {
        .speed          = USB_SPEED_HIGH,
 
-       .bind           = composite_bind,
        .unbind         = composite_unbind,
 
        .setup          = composite_setup,
@@ -1255,7 +1254,7 @@ int usb_composite_register(struct usb_composite_driver *driver)
        composite_driver.driver.name = driver->name;
        composite = driver;
 
-       return usb_gadget_register_driver(&composite_driver);
+       return usb_gadget_probe_driver(&composite_driver, composite_bind);
 }
 
 /**
index abe4a2ec56254e62bbc8e3b60784c8a36a854d59..e5ac8a316fecb7a7899c996b6f57f57089028f98 100644 (file)
@@ -403,7 +403,6 @@ fail:
 static struct usb_gadget_driver dbgp_driver = {
        .function = "dbgp",
        .speed = USB_SPEED_HIGH,
-       .bind = dbgp_bind,
        .unbind = dbgp_unbind,
        .setup = dbgp_setup,
        .disconnect = dbgp_disconnect,
@@ -415,7 +414,7 @@ static struct usb_gadget_driver dbgp_driver = {
 
 static int __init dbgp_init(void)
 {
-       return usb_gadget_register_driver(&dbgp_driver);
+       return usb_gadget_probe_driver(&dbgp_driver, dbgp_bind);
 }
 
 static void __exit dbgp_exit(void)
index dc6546248ed99407eefef93ef850b9a5980b23e5..7bb9d78aac2736cae940360189fbf64dcb3900b8 100644 (file)
@@ -748,7 +748,8 @@ static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
  */
 
 int
-usb_gadget_register_driver (struct usb_gadget_driver *driver)
+usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct dummy    *dum = the_controller;
        int             retval, i;
@@ -757,8 +758,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
                return -EINVAL;
        if (dum->driver)
                return -EBUSY;
-       if (!driver->bind || !driver->setup
-                       || driver->speed == USB_SPEED_UNKNOWN)
+       if (!bind || !driver->setup || driver->speed == USB_SPEED_UNKNOWN)
                return -EINVAL;
 
        /*
@@ -796,7 +796,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
        dum->gadget.dev.driver = &driver->driver;
        dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n",
                        driver->driver.name);
-       retval = driver->bind(&dum->gadget);
+       retval = bind(&dum->gadget);
        if (retval) {
                dum->driver = NULL;
                dum->gadget.dev.driver = NULL;
@@ -812,7 +812,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
        usb_hcd_poll_rh_status (dummy_to_hcd (dum));
        return 0;
 }
-EXPORT_SYMBOL (usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int
 usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
index aae04c20b0eade080fb0ee279ed49922b5c44acd..132a1c0877bd1f4a89505a9288179aa9b4cfed2f 100644 (file)
@@ -3608,7 +3608,6 @@ static struct usb_gadget_driver           fsg_driver = {
        .speed          = USB_SPEED_FULL,
 #endif
        .function       = (char *) fsg_string_product,
-       .bind           = fsg_bind,
        .unbind         = fsg_unbind,
        .disconnect     = fsg_disconnect,
        .setup          = fsg_setup,
@@ -3650,7 +3649,7 @@ static int __init fsg_init(void)
        if ((rc = fsg_alloc()) != 0)
                return rc;
        fsg = the_fsg;
-       if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0)
+       if ((rc = usb_gadget_probe_driver(&fsg_driver, fsg_bind)) != 0)
                kref_put(&fsg->ref, fsg_release);
        return rc;
 }
index a5ea2c1d8c93353d68dfe5ef2dbfff597acb5dfe..792d5ef4013737ab4ec48971b5985a3af3aad549 100644 (file)
@@ -2302,9 +2302,10 @@ static irqreturn_t qe_udc_irq(int irq, void *_udc)
 }
 
 /*-------------------------------------------------------------------------
-       Gadget driver register and unregister.
+       Gadget driver probe and unregister.
  --------------------------------------------------------------------------*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        int retval;
        unsigned long flags = 0;
@@ -2315,8 +2316,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        if (!driver || (driver->speed != USB_SPEED_FULL
                        && driver->speed != USB_SPEED_HIGH)
-                       || !driver->bind || !driver->disconnect
-                       || !driver->setup)
+                       || !bind || !driver->disconnect || !driver->setup)
                return -EINVAL;
 
        if (udc_controller->driver)
@@ -2332,7 +2332,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed);
        spin_unlock_irqrestore(&udc_controller->lock, flags);
 
-       retval = driver->bind(&udc_controller->gadget);
+       retval = bind(&udc_controller->gadget);
        if (retval) {
                dev_err(udc_controller->dev, "bind to %s --> %d",
                                driver->driver.name, retval);
@@ -2353,7 +2353,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                udc_controller->gadget.name, driver->driver.name);
        return 0;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 {
index 08a9a62a39e34910ecbcb3fdb8381c044fa851e4..c16b402a876b6008357cd0852b11d2c79af34b2b 100644 (file)
@@ -1765,7 +1765,8 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc)
  * Hook to gadget drivers
  * Called by initialization code of gadget drivers
 *----------------------------------------------------------------*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        int retval = -ENODEV;
        unsigned long flags = 0;
@@ -1775,8 +1776,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        if (!driver || (driver->speed != USB_SPEED_FULL
                                && driver->speed != USB_SPEED_HIGH)
-                       || !driver->bind || !driver->disconnect
-                       || !driver->setup)
+                       || !bind || !driver->disconnect || !driver->setup)
                return -EINVAL;
 
        if (udc_controller->driver)
@@ -1792,7 +1792,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        spin_unlock_irqrestore(&udc_controller->lock, flags);
 
        /* bind udc driver to gadget driver */
-       retval = driver->bind(&udc_controller->gadget);
+       retval = bind(&udc_controller->gadget);
        if (retval) {
                VDBG("bind to %s --> %d", driver->driver.name, retval);
                udc_controller->gadget.dev.driver = NULL;
@@ -1814,7 +1814,7 @@ out:
                       retval);
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 /* Disconnect from gadget driver */
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
index b7bf88019b06faae1fbbc6792c63efb0b809bf0d..0ab7e141d4940061f489b8862479a3e58d19df16 100644 (file)
@@ -1292,7 +1292,6 @@ static void gmidi_resume(struct usb_gadget *gadget)
 static struct usb_gadget_driver gmidi_driver = {
        .speed          = USB_SPEED_FULL,
        .function       = (char *)longname,
-       .bind           = gmidi_bind,
        .unbind         = gmidi_unbind,
 
        .setup          = gmidi_setup,
@@ -1309,7 +1308,7 @@ static struct usb_gadget_driver gmidi_driver = {
 
 static int __init gmidi_init(void)
 {
-       return usb_gadget_register_driver(&gmidi_driver);
+       return usb_gadget_probe_driver(&gmidi_driver, gmidi_bind);
 }
 module_init(gmidi_init);
 
index 1088d08c7ed8fac07146bd8d6fbde9d59a1897ca..49fbd4dbeb94a685426de1e3aa36945c204df952 100644 (file)
@@ -1343,14 +1343,15 @@ static struct goku_udc  *the_controller;
  * disconnect is reported.  then a host may connect again, or
  * the driver might get unbound.
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct goku_udc *dev = the_controller;
        int                     retval;
 
        if (!driver
                        || driver->speed < USB_SPEED_FULL
-                       || !driver->bind
+                       || !bind
                        || !driver->disconnect
                        || !driver->setup)
                return -EINVAL;
@@ -1363,7 +1364,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        driver->driver.bus = NULL;
        dev->driver = driver;
        dev->gadget.dev.driver = &driver->driver;
-       retval = driver->bind(&dev->gadget);
+       retval = bind(&dev->gadget);
        if (retval) {
                DBG(dev, "bind to driver %s --> error %d\n",
                                driver->driver.name, retval);
@@ -1380,7 +1381,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        DBG(dev, "registered gadget driver '%s'\n", driver->driver.name);
        return 0;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 static void
 stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver)
index e743122fcd93e0f74ec23f8b1f0efa050d9a5f10..ed0266462c5736628f40a7570566b583f6dd7d81 100644 (file)
@@ -1319,14 +1319,15 @@ static struct imx_udc_struct controller = {
  * USB gadged driver functions
  *******************************************************************************
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct imx_udc_struct *imx_usb = &controller;
        int retval;
 
        if (!driver
                || driver->speed < USB_SPEED_FULL
-               || !driver->bind
+               || !bind
                || !driver->disconnect
                || !driver->setup)
                        return -EINVAL;
@@ -1342,7 +1343,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        retval = device_add(&imx_usb->gadget.dev);
        if (retval)
                goto fail;
-       retval = driver->bind(&imx_usb->gadget);
+       retval = bind(&imx_usb->gadget);
        if (retval) {
                D_ERR(imx_usb->dev, "<%s> bind to driver %s --> error %d\n",
                        __func__, driver->driver.name, retval);
@@ -1362,7 +1363,7 @@ fail:
        imx_usb->gadget.dev.driver = NULL;
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 {
index fc35406fc80c3e72562bbb96068f99e462663842..e2e8eda83f0dd522936245955af150430a57cbc6 100644 (file)
@@ -1775,7 +1775,6 @@ static struct usb_gadget_driver gadgetfs_driver = {
        .speed          = USB_SPEED_FULL,
 #endif
        .function       = (char *) driver_desc,
-       .bind           = gadgetfs_bind,
        .unbind         = gadgetfs_unbind,
        .setup          = gadgetfs_setup,
        .disconnect     = gadgetfs_disconnect,
@@ -1798,7 +1797,6 @@ static int gadgetfs_probe (struct usb_gadget *gadget)
 
 static struct usb_gadget_driver probe_driver = {
        .speed          = USB_SPEED_HIGH,
-       .bind           = gadgetfs_probe,
        .unbind         = gadgetfs_nop,
        .setup          = (void *)gadgetfs_nop,
        .disconnect     = gadgetfs_nop,
@@ -1908,7 +1906,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 
        /* triggers gadgetfs_bind(); then we can enumerate. */
        spin_unlock_irq (&dev->lock);
-       value = usb_gadget_register_driver (&gadgetfs_driver);
+       value = usb_gadget_probe_driver(&gadgetfs_driver, gadgetfs_bind);
        if (value != 0) {
                kfree (dev->buf);
                dev->buf = NULL;
@@ -2047,7 +2045,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
                return -ESRCH;
 
        /* fake probe to determine $CHIP */
-       (void) usb_gadget_register_driver (&probe_driver);
+       (void) usb_gadget_probe_driver(&probe_driver, gadgetfs_probe);
        if (!CHIP)
                return -ENODEV;
 
index ccc9c070a30d522662ca884ff7ff89f6fe052dbb..1ef17a6dcb511bd80a41e6e6e57f4969cef7bb83 100644 (file)
@@ -1855,7 +1855,8 @@ static DEVICE_ATTR(remote_wakeup, S_IWUSR, NULL, store_remote_wakeup);
  * the driver might get unbound.
  */
 
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct langwell_udc     *dev = the_controller;
        unsigned long           flags;
@@ -1878,7 +1879,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        spin_unlock_irqrestore(&dev->lock, flags);
 
-       retval = driver->bind(&dev->gadget);
+       retval = bind(&dev->gadget);
        if (retval) {
                dev_dbg(&dev->pdev->dev, "bind to driver %s --> %d\n",
                                driver->driver.name, retval);
@@ -1916,7 +1917,7 @@ err_unbind:
        dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 
 /* unregister gadget driver */
@@ -1930,7 +1931,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 
        dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
 
-       if (unlikely(!driver || !driver->bind || !driver->unbind))
+       if (unlikely(!driver || !driver->unbind))
                return -EINVAL;
 
        /* exit PHY low power suspend */
index fded3fca793b5850add32e2cb9798740cf6e02f3..6b58bd8ce62395bbbef54803e51380c0ed138b3b 100644 (file)
@@ -408,7 +408,8 @@ static void udc_enable(struct lh7a40x_udc *dev)
 /*
   Register entry point for the peripheral controller driver.
 */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct lh7a40x_udc *dev = the_controller;
        int retval;
@@ -417,7 +418,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        if (!driver
                        || driver->speed != USB_SPEED_FULL
-                       || !driver->bind
+                       || !bind
                        || !driver->disconnect
                        || !driver->setup)
                return -EINVAL;
@@ -431,7 +432,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        dev->gadget.dev.driver = &driver->driver;
 
        device_add(&dev->gadget.dev);
-       retval = driver->bind(&dev->gadget);
+       retval = bind(&dev->gadget);
        if (retval) {
                printk(KERN_WARNING "%s: bind to driver %s --> error %d\n",
                       dev->gadget.name, driver->driver.name, retval);
@@ -453,8 +454,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        return 0;
 }
-
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 /*
   Unregister entry point for the peripheral controller driver.
index e03058fe23cbc91394474e1130aed8fcaa6c5f84..51b19f3027e7bb94b37a2771b36f646837479ae5 100644 (file)
@@ -1454,14 +1454,15 @@ static struct usb_ep_ops m66592_ep_ops = {
 /*-------------------------------------------------------------------------*/
 static struct m66592 *the_controller;
 
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct m66592 *m66592 = the_controller;
        int retval;
 
        if (!driver
                        || driver->speed != USB_SPEED_HIGH
-                       || !driver->bind
+                       || !bind
                        || !driver->setup)
                return -EINVAL;
        if (!m66592)
@@ -1480,7 +1481,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                goto error;
        }
 
-       retval = driver->bind (&m66592->gadget);
+       retval = bind(&m66592->gadget);
        if (retval) {
                pr_err("bind to driver error (%d)\n", retval);
                device_del(&m66592->gadget.dev);
@@ -1505,7 +1506,7 @@ error:
 
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 {
index 9498be87a72450dd2e31c9945351a1924f753c90..d09155b25d73c98d8f7b9dd2028b75433556d3d2 100644 (file)
@@ -1929,7 +1929,8 @@ static void ep0_start (struct net2280 *dev)
  * disconnect is reported.  then a host may connect again, or
  * the driver might get unbound.
  */
-int usb_gadget_register_driver (struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct net2280          *dev = the_controller;
        int                     retval;
@@ -1941,8 +1942,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
         */
        if (!driver
                        || driver->speed != USB_SPEED_HIGH
-                       || !driver->bind
-                       || !driver->setup)
+                       || !bind || !driver->setup)
                return -EINVAL;
        if (!dev)
                return -ENODEV;
@@ -1957,7 +1957,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
        driver->driver.bus = NULL;
        dev->driver = driver;
        dev->gadget.dev.driver = &driver->driver;
-       retval = driver->bind (&dev->gadget);
+       retval = bind(&dev->gadget);
        if (retval) {
                DEBUG (dev, "bind to driver %s --> %d\n",
                                driver->driver.name, retval);
@@ -1993,7 +1993,7 @@ err_unbind:
        dev->driver = NULL;
        return retval;
 }
-EXPORT_SYMBOL (usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 static void
 stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
index f81e4f025f239fe3cfeaf4af1dd17d5c5248d7cf..61d3ca6619bb1fec36204f812915a5ebe6e7c37c 100644 (file)
@@ -2102,7 +2102,8 @@ static inline int machine_without_vbus_sense(void)
                );
 }
 
-int usb_gadget_register_driver (struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        int             status = -ENODEV;
        struct omap_ep  *ep;
@@ -2114,8 +2115,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
        if (!driver
                        // FIXME if otg, check:  driver->is_otg
                        || driver->speed < USB_SPEED_FULL
-                       || !driver->bind
-                       || !driver->setup)
+                       || !bind || !driver->setup)
                return -EINVAL;
 
        spin_lock_irqsave(&udc->lock, flags);
@@ -2145,7 +2145,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
        if (udc->dc_clk != NULL)
                omap_udc_enable_clock(1);
 
-       status = driver->bind (&udc->gadget);
+       status = bind(&udc->gadget);
        if (status) {
                DBG("bind to %s --> %d\n", driver->driver.name, status);
                udc->gadget.dev.driver = NULL;
@@ -2186,7 +2186,7 @@ done:
                omap_udc_enable_clock(0);
        return status;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
 {
index 04c7bbf121aff61432a1401d3c5ff0c709c45178..ded080a1c8ce5f3967824b4d89abd7e03d0ef9f6 100644 (file)
@@ -1543,7 +1543,6 @@ static struct usb_gadget_driver printer_driver = {
        .speed          = DEVSPEED,
 
        .function       = (char *) driver_desc,
-       .bind           = printer_bind,
        .unbind         = printer_unbind,
 
        .setup          = printer_setup,
@@ -1579,11 +1578,11 @@ init(void)
                return status;
        }
 
-       status = usb_gadget_register_driver(&printer_driver);
+       status = usb_gadget_probe_driver(&printer_driver, printer_bind);
        if (status) {
                class_destroy(usb_gadget_class);
                unregister_chrdev_region(g_printer_devno, 1);
-               DBG(dev, "usb_gadget_register_driver %x\n", status);
+               DBG(dev, "usb_gadget_probe_driver %x\n", status);
        }
 
        return status;
index be5fb34d9602366d520cd0fbe905a1d75b0e1025..b37f92cb71bc81ebad6953650c96d9f982212420 100644 (file)
@@ -1280,14 +1280,15 @@ static void udc_enable (struct pxa25x_udc *dev)
  * disconnect is reported.  then a host may connect again, or
  * the driver might get unbound.
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct pxa25x_udc       *dev = the_controller;
        int                     retval;
 
        if (!driver
                        || driver->speed < USB_SPEED_FULL
-                       || !driver->bind
+                       || !bind
                        || !driver->disconnect
                        || !driver->setup)
                return -EINVAL;
@@ -1308,7 +1309,7 @@ fail:
                dev->gadget.dev.driver = NULL;
                return retval;
        }
-       retval = driver->bind(&dev->gadget);
+       retval = bind(&dev->gadget);
        if (retval) {
                DMSG("bind to driver %s --> error %d\n",
                                driver->driver.name, retval);
@@ -1338,7 +1339,7 @@ fail:
 bind_fail:
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 static void
 stop_activity(struct pxa25x_udc *dev, struct usb_gadget_driver *driver)
index 980762453a9c293d6bdda38bdc54317c55a3433c..027d66f816209d0b8f5638754118c083880eafb8 100644 (file)
@@ -1792,8 +1792,9 @@ static void udc_enable(struct pxa_udc *udc)
 }
 
 /**
- * usb_gadget_register_driver - Register gadget driver
+ * usb_gadget_probe_driver - Register gadget driver
  * @driver: gadget driver
+ * @bind: bind function
  *
  * When a driver is successfully registered, it will receive control requests
  * including set_configuration(), which enables non-control requests.  Then
@@ -1805,12 +1806,13 @@ static void udc_enable(struct pxa_udc *udc)
  *
  * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct pxa_udc *udc = the_controller;
        int retval;
 
-       if (!driver || driver->speed < USB_SPEED_FULL || !driver->bind
+       if (!driver || driver->speed < USB_SPEED_FULL || !bind
                        || !driver->disconnect || !driver->setup)
                return -EINVAL;
        if (!udc)
@@ -1828,7 +1830,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                dev_err(udc->dev, "device_add error %d\n", retval);
                goto add_fail;
        }
-       retval = driver->bind(&udc->gadget);
+       retval = bind(&udc->gadget);
        if (retval) {
                dev_err(udc->dev, "bind to driver %s --> error %d\n",
                        driver->driver.name, retval);
@@ -1859,7 +1861,7 @@ add_fail:
        udc->gadget.dev.driver = NULL;
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 
 /**
index 2456ccd9965e3432ab4fd32a33052c104e725698..95092151f901c8a564c0491a0d6fff206c6b3b93 100644 (file)
@@ -1405,14 +1405,15 @@ static struct usb_ep_ops r8a66597_ep_ops = {
 /*-------------------------------------------------------------------------*/
 static struct r8a66597 *the_controller;
 
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct r8a66597 *r8a66597 = the_controller;
        int retval;
 
        if (!driver
                        || driver->speed != USB_SPEED_HIGH
-                       || !driver->bind
+                       || !bind
                        || !driver->setup)
                return -EINVAL;
        if (!r8a66597)
@@ -1431,7 +1432,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                goto error;
        }
 
-       retval = driver->bind(&r8a66597->gadget);
+       retval = bind(&r8a66597->gadget);
        if (retval) {
                printk(KERN_ERR "bind to driver error (%d)\n", retval);
                device_del(&r8a66597->gadget.dev);
@@ -1456,7 +1457,7 @@ error:
 
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 {
index a229744a8c7dfa4d5f284165800a455d8f687b26..ef825c3baed966b69a00a454f254f1814bb29650 100644 (file)
@@ -2523,7 +2523,8 @@ static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg)
        return 0;
 }
 
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct s3c_hsotg *hsotg = our_hsotg;
        int ret;
@@ -2543,7 +2544,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                dev_err(hsotg->dev, "%s: bad speed\n", __func__);
        }
 
-       if (!driver->bind || !driver->setup) {
+       if (!bind || !driver->setup) {
                dev_err(hsotg->dev, "%s: missing entry points\n", __func__);
                return -EINVAL;
        }
@@ -2562,7 +2563,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                goto err;
        }
 
-       ret = driver->bind(&hsotg->gadget);
+       ret = bind(&hsotg->gadget);
        if (ret) {
                dev_err(hsotg->dev, "failed bind %s\n", driver->driver.name);
 
@@ -2687,7 +2688,7 @@ err:
        hsotg->gadget.dev.driver = NULL;
        return ret;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 {
index ea2b3c7ebee50d6d93e498ea2c37a995e2a5ed3e..c2448950a8d8031dcd856a0cbafe3f6710f0a617 100644 (file)
@@ -1632,15 +1632,15 @@ static void s3c2410_udc_enable(struct s3c2410_udc *dev)
 }
 
 /*
- *     usb_gadget_register_driver
+ *     usb_gadget_probe_driver
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        struct s3c2410_udc *udc = the_controller;
        int             retval;
 
-       dprintk(DEBUG_NORMAL, "usb_gadget_register_driver() '%s'\n",
-               driver->driver.name);
+       dprintk(DEBUG_NORMAL, "%s() '%s'\n", __func__, driver->driver.name);
 
        /* Sanity checks */
        if (!udc)
@@ -1649,10 +1649,9 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        if (udc->driver)
                return -EBUSY;
 
-       if (!driver->bind || !driver->setup
-                       || driver->speed < USB_SPEED_FULL) {
+       if (!bind || !driver->setup || driver->speed < USB_SPEED_FULL) {
                printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n",
-                       driver->bind, driver->setup, driver->speed);
+                       bind, driver->setup, driver->speed);
                return -EINVAL;
        }
 #if defined(MODULE)
@@ -1675,7 +1674,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n",
                driver->driver.name);
 
-       if ((retval = driver->bind (&udc->gadget)) != 0) {
+       if ((retval = bind(&udc->gadget)) != 0) {
                device_del(&udc->gadget.dev);
                goto register_error;
        }
@@ -1690,6 +1689,7 @@ register_error:
        udc->gadget.dev.driver = NULL;
        return retval;
 }
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 /*
  *     usb_gadget_unregister_driver
@@ -2049,7 +2049,6 @@ static void __exit udc_exit(void)
 }
 
 EXPORT_SYMBOL(usb_gadget_unregister_driver);
-EXPORT_SYMBOL(usb_gadget_register_driver);
 
 module_init(udc_init);
 module_exit(udc_exit);
index d065e23f123ee755f9e6fe0e661823f48d917727..ecd5f8cffcbf71a951fb1c7a06bedd64ef6fc8b0 100644 (file)
@@ -1699,9 +1699,11 @@ void musb_gadget_cleanup(struct musb *musb)
  * -ENOMEM no memeory to perform the operation
  *
  * @param driver the gadget driver
+ * @param bind the driver's bind function
  * @return <0 if error, 0 if everything is fine
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *))
 {
        int retval;
        unsigned long flags;
@@ -1709,8 +1711,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        if (!driver
                        || driver->speed != USB_SPEED_HIGH
-                       || !driver->bind
-                       || !driver->setup)
+                       || !bind || !driver->setup)
                return -EINVAL;
 
        /* driver must be initialized to support peripheral mode */
@@ -1738,7 +1739,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        spin_unlock_irqrestore(&musb->lock, flags);
 
        if (retval == 0) {
-               retval = driver->bind(&musb->g);
+               retval = bind(&musb->g);
                if (retval != 0) {
                        DBG(3, "bind to driver %s failed --> %d\n",
                                        driver->driver.name, retval);
@@ -1786,7 +1787,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
        return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
 
 static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver)
 {
index d3ef42d7d2f0d02367b42f62bcf1678f97334108..006412ce2303881200e7da14446a078ddaa37f2e 100644 (file)
@@ -705,11 +705,6 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
  * struct usb_gadget_driver - driver for usb 'slave' devices
  * @function: String describing the gadget's function
  * @speed: Highest speed the driver handles.
- * @bind: Invoked when the driver is bound to a gadget, usually
- *     after registering the driver.
- *     At that point, ep0 is fully initialized, and ep_list holds
- *     the currently-available endpoints.
- *     Called in a context that permits sleeping.
  * @setup: Invoked for ep0 control requests that aren't handled by
  *     the hardware level driver. Most calls must be handled by
  *     the gadget driver, including descriptor and configuration
@@ -774,7 +769,6 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
 struct usb_gadget_driver {
        char                    *function;
        enum usb_device_speed   speed;
-       int                     (*bind)(struct usb_gadget *);
        void                    (*unbind)(struct usb_gadget *);
        int                     (*setup)(struct usb_gadget *,
                                        const struct usb_ctrlrequest *);
@@ -798,17 +792,19 @@ struct usb_gadget_driver {
  */
 
 /**
- * usb_gadget_register_driver - register a gadget driver
- * @driver:the driver being registered
+ * usb_gadget_probe_driver - probe a gadget driver
+ * @driver: the driver being registered
+ * @bind: the driver's bind callback
  * Context: can sleep
  *
  * Call this in your gadget driver's module initialization function,
  * to tell the underlying usb controller driver about your driver.
- * The driver's bind() function will be called to bind it to a
- * gadget before this registration call returns.  It's expected that
- * the bind() functions will be in init sections.
+ * The @bind() function will be called to bind it to a gadget before this
+ * registration call returns.  It's expected that the @bind() function will
+ * be in init sections.
  */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver);
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+               int (*bind)(struct usb_gadget *));
 
 /**
  * usb_gadget_unregister_driver - unregister a gadget driver