1
0
Fork 0

usb: gadget: remove global variable composite in composite.c

This patch removes the global variable composite in composite.c.
The private data which was saved there is now passed via an additional
argument to the bind() function in struct usb_gadget_driver.

Only the "old-style" UDC drivers have to be touched here, new style are
doing it right because this change is made in udc-core.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
hifive-unleashed-5.1
Sebastian Andrzej Siewior 2012-09-07 09:53:17 +02:00 committed by Felipe Balbi
parent e220ff75db
commit ffe0b33506
19 changed files with 78 additions and 63 deletions

View File

@ -1422,7 +1422,8 @@ static u8 override_id(struct usb_composite_dev *cdev, u8 *desc)
return *desc; return *desc;
} }
static int composite_bind(struct usb_gadget *gadget) static int composite_bind(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{ {
struct usb_composite_dev *cdev; struct usb_composite_dev *cdev;
int status = -ENOMEM; int status = -ENOMEM;

View File

@ -1401,7 +1401,7 @@ static int udc_wakeup(struct usb_gadget *gadget)
} }
static int amd5536_start(struct usb_gadget_driver *driver, static int amd5536_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int amd5536_stop(struct usb_gadget_driver *driver); static int amd5536_stop(struct usb_gadget_driver *driver);
/* gadget operations */ /* gadget operations */
static const struct usb_gadget_ops udc_ops = { static const struct usb_gadget_ops udc_ops = {
@ -1914,7 +1914,7 @@ static int setup_ep0(struct udc *dev)
/* Called by gadget driver to register itself */ /* Called by gadget driver to register itself */
static int amd5536_start(struct usb_gadget_driver *driver, static int amd5536_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct udc *dev = udc; struct udc *dev = udc;
int retval; int retval;
@ -1932,7 +1932,7 @@ static int amd5536_start(struct usb_gadget_driver *driver,
dev->driver = driver; dev->driver = driver;
dev->gadget.dev.driver = &driver->driver; dev->gadget.dev.driver = &driver->driver;
retval = bind(&dev->gadget); retval = bind(&dev->gadget, driver);
/* Some gadget drivers use both ep0 directions. /* Some gadget drivers use both ep0 directions.
* NOTE: to gadget driver, ep0 is just one endpoint... * NOTE: to gadget driver, ep0 is just one endpoint...

View File

@ -31,8 +31,6 @@
/* big enough to hold our biggest descriptor */ /* big enough to hold our biggest descriptor */
#define USB_BUFSIZ 1024 #define USB_BUFSIZ 1024
static struct usb_composite_driver *composite;
/* Some systems will need runtime overrides for the product identifiers /* Some systems will need runtime overrides for the product identifiers
* published in the device descriptor, either numbers or strings or both. * published in the device descriptor, either numbers or strings or both.
* String parameters are in UTF-8 (superset of ASCII's 7 bit characters). * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
@ -889,6 +887,7 @@ static int lookup_string(
static int get_string(struct usb_composite_dev *cdev, static int get_string(struct usb_composite_dev *cdev,
void *buf, u16 language, int id) void *buf, u16 language, int id)
{ {
struct usb_composite_driver *composite = cdev->driver;
struct usb_configuration *c; struct usb_configuration *c;
struct usb_function *f; struct usb_function *f;
int len; int len;
@ -1359,8 +1358,8 @@ static void composite_disconnect(struct usb_gadget *gadget)
spin_lock_irqsave(&cdev->lock, flags); spin_lock_irqsave(&cdev->lock, flags);
if (cdev->config) if (cdev->config)
reset_config(cdev); reset_config(cdev);
if (composite->disconnect) if (cdev->driver->disconnect)
composite->disconnect(cdev); cdev->driver->disconnect(cdev);
spin_unlock_irqrestore(&cdev->lock, flags); spin_unlock_irqrestore(&cdev->lock, flags);
} }
@ -1396,8 +1395,8 @@ composite_unbind(struct usb_gadget *gadget)
struct usb_configuration, list); struct usb_configuration, list);
remove_config(cdev, c); remove_config(cdev, c);
} }
if (composite->unbind) if (cdev->driver->unbind)
composite->unbind(cdev); cdev->driver->unbind(cdev);
if (cdev->req) { if (cdev->req) {
kfree(cdev->req->buf); kfree(cdev->req->buf);
@ -1406,7 +1405,6 @@ composite_unbind(struct usb_gadget *gadget)
device_remove_file(&gadget->dev, &dev_attr_suspended); device_remove_file(&gadget->dev, &dev_attr_suspended);
kfree(cdev); kfree(cdev);
set_gadget_data(gadget, NULL); set_gadget_data(gadget, NULL);
composite = NULL;
} }
static u8 override_id(struct usb_composite_dev *cdev, u8 *desc) static u8 override_id(struct usb_composite_dev *cdev, u8 *desc)
@ -1422,9 +1420,16 @@ static u8 override_id(struct usb_composite_dev *cdev, u8 *desc)
return *desc; return *desc;
} }
static int composite_bind(struct usb_gadget *gadget) static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv)
{
return container_of(gdrv, struct usb_composite_driver, gadget_driver);
}
static int composite_bind(struct usb_gadget *gadget,
struct usb_gadget_driver *gdriver)
{ {
struct usb_composite_dev *cdev; struct usb_composite_dev *cdev;
struct usb_composite_driver *composite = to_cdriver(gdriver);
int status = -ENOMEM; int status = -ENOMEM;
cdev = kzalloc(sizeof *cdev, GFP_KERNEL); cdev = kzalloc(sizeof *cdev, GFP_KERNEL);
@ -1546,8 +1551,8 @@ composite_suspend(struct usb_gadget *gadget)
f->suspend(f); f->suspend(f);
} }
} }
if (composite->suspend) if (cdev->driver->suspend)
composite->suspend(cdev); cdev->driver->suspend(cdev);
cdev->suspended = 1; cdev->suspended = 1;
@ -1565,8 +1570,8 @@ composite_resume(struct usb_gadget *gadget)
* suspend/resume callbacks? * suspend/resume callbacks?
*/ */
DBG(cdev, "resume\n"); DBG(cdev, "resume\n");
if (composite->resume) if (cdev->driver->resume)
composite->resume(cdev); cdev->driver->resume(cdev);
if (cdev->config) { if (cdev->config) {
list_for_each_entry(f, &cdev->config->functions, list) { list_for_each_entry(f, &cdev->config->functions, list) {
if (f->resume) if (f->resume)
@ -1584,7 +1589,7 @@ composite_resume(struct usb_gadget *gadget)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static struct usb_gadget_driver composite_driver = { static const struct usb_gadget_driver composite_driver_template = {
.bind = composite_bind, .bind = composite_bind,
.unbind = composite_unbind, .unbind = composite_unbind,
@ -1620,19 +1625,24 @@ static struct usb_gadget_driver composite_driver = {
*/ */
int usb_composite_probe(struct usb_composite_driver *driver) int usb_composite_probe(struct usb_composite_driver *driver)
{ {
if (!driver || !driver->dev || composite || !driver->bind) struct usb_gadget_driver *gadget_driver;
if (!driver || !driver->dev || !driver->bind)
return -EINVAL; return -EINVAL;
if (!driver->name) if (!driver->name)
driver->name = "composite"; driver->name = "composite";
if (!driver->iProduct) if (!driver->iProduct)
driver->iProduct = driver->name; driver->iProduct = driver->name;
composite_driver.function = (char *) driver->name;
composite_driver.driver.name = driver->name;
composite_driver.max_speed = driver->max_speed;
composite = driver;
return usb_gadget_probe_driver(&composite_driver); driver->gadget_driver = composite_driver_template;
gadget_driver = &driver->gadget_driver;
gadget_driver->function = (char *) driver->name;
gadget_driver->driver.name = driver->name;
gadget_driver->max_speed = driver->max_speed;
return usb_gadget_probe_driver(gadget_driver);
} }
/** /**
@ -1644,9 +1654,7 @@ int usb_composite_probe(struct usb_composite_driver *driver)
*/ */
void usb_composite_unregister(struct usb_composite_driver *driver) void usb_composite_unregister(struct usb_composite_driver *driver)
{ {
if (composite != driver) usb_gadget_unregister_driver(&driver->gadget_driver);
return;
usb_gadget_unregister_driver(&composite_driver);
} }
/** /**

View File

@ -292,7 +292,8 @@ fail_1:
return -ENODEV; return -ENODEV;
} }
static int __init dbgp_bind(struct usb_gadget *gadget) static int __init dbgp_bind(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{ {
int err, stp; int err, stp;

View File

@ -3331,7 +3331,8 @@ static int __init check_parameters(struct fsg_dev *fsg)
} }
static int __init fsg_bind(struct usb_gadget *gadget) static int __init fsg_bind(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{ {
struct fsg_dev *fsg = the_fsg; struct fsg_dev *fsg = the_fsg;
int rc; int rc;

View File

@ -1255,7 +1255,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on)
} }
static int fsl_start(struct usb_gadget_driver *driver, static int fsl_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int fsl_stop(struct usb_gadget_driver *driver); static int fsl_stop(struct usb_gadget_driver *driver);
/* defined in gadget.h */ /* defined in gadget.h */
static struct usb_gadget_ops fsl_gadget_ops = { static struct usb_gadget_ops fsl_gadget_ops = {
@ -1951,7 +1951,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc)
* Called by initialization code of gadget drivers * Called by initialization code of gadget drivers
*----------------------------------------------------------------*/ *----------------------------------------------------------------*/
static int fsl_start(struct usb_gadget_driver *driver, static int fsl_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
int retval = -ENODEV; int retval = -ENODEV;
unsigned long flags = 0; unsigned long flags = 0;
@ -1976,7 +1976,7 @@ static int fsl_start(struct usb_gadget_driver *driver,
spin_unlock_irqrestore(&udc_controller->lock, flags); spin_unlock_irqrestore(&udc_controller->lock, flags);
/* bind udc driver to gadget driver */ /* bind udc driver to gadget driver */
retval = bind(&udc_controller->gadget); retval = bind(&udc_controller->gadget, driver);
if (retval) { if (retval) {
VDBG("bind to %s --> %d", driver->driver.name, retval); VDBG("bind to %s --> %d", driver->driver.name, retval);
udc_controller->gadget.dev.driver = NULL; udc_controller->gadget.dev.driver = NULL;

View File

@ -1311,7 +1311,7 @@ static void init_controller(struct fusb300 *fusb300)
static struct fusb300 *the_controller; static struct fusb300 *the_controller;
static int fusb300_udc_start(struct usb_gadget_driver *driver, static int fusb300_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct fusb300 *fusb300 = the_controller; struct fusb300 *fusb300 = the_controller;
int retval; int retval;
@ -1339,7 +1339,7 @@ static int fusb300_udc_start(struct usb_gadget_driver *driver,
goto error; goto error;
} }
retval = bind(&fusb300->gadget); retval = bind(&fusb300->gadget, driver);
if (retval) { if (retval) {
pr_err("bind to driver error (%d)\n", retval); pr_err("bind to driver error (%d)\n", retval);
device_del(&fusb300->gadget.dev); device_del(&fusb300->gadget.dev);

View File

@ -994,7 +994,7 @@ static int goku_get_frame(struct usb_gadget *_gadget)
} }
static int goku_start(struct usb_gadget_driver *driver, static int goku_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int goku_stop(struct usb_gadget_driver *driver); static int goku_stop(struct usb_gadget_driver *driver);
static const struct usb_gadget_ops goku_ops = { static const struct usb_gadget_ops goku_ops = {
@ -1348,7 +1348,7 @@ static struct goku_udc *the_controller;
* the driver might get unbound. * the driver might get unbound.
*/ */
static int goku_start(struct usb_gadget_driver *driver, static int goku_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct goku_udc *dev = the_controller; struct goku_udc *dev = the_controller;
int retval; int retval;
@ -1368,7 +1368,7 @@ static int goku_start(struct usb_gadget_driver *driver,
driver->driver.bus = NULL; driver->driver.bus = NULL;
dev->driver = driver; dev->driver = driver;
dev->gadget.dev.driver = &driver->driver; dev->gadget.dev.driver = &driver->driver;
retval = bind(&dev->gadget); retval = bind(&dev->gadget, driver);
if (retval) { if (retval) {
DBG(dev, "bind to driver %s --> error %d\n", DBG(dev, "bind to driver %s --> error %d\n",
driver->driver.name, retval); driver->driver.name, retval);

View File

@ -1679,8 +1679,8 @@ gadgetfs_unbind (struct usb_gadget *gadget)
static struct dev_data *the_device; static struct dev_data *the_device;
static int static int gadgetfs_bind(struct usb_gadget *gadget,
gadgetfs_bind (struct usb_gadget *gadget) struct usb_gadget_driver *driver)
{ {
struct dev_data *dev = the_device; struct dev_data *dev = the_device;
@ -1773,7 +1773,8 @@ static struct usb_gadget_driver gadgetfs_driver = {
static void gadgetfs_nop(struct usb_gadget *arg) { } static void gadgetfs_nop(struct usb_gadget *arg) { }
static int gadgetfs_probe (struct usb_gadget *gadget) static int gadgetfs_probe(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{ {
CHIP = gadget->name; CHIP = gadget->name;
return -EISNAM; return -EISNAM;

View File

@ -1466,7 +1466,7 @@ static struct usb_ep_ops m66592_ep_ops = {
static struct m66592 *the_controller; static struct m66592 *the_controller;
static int m66592_start(struct usb_gadget_driver *driver, static int m66592_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct m66592 *m66592 = the_controller; struct m66592 *m66592 = the_controller;
int retval; int retval;
@ -1492,7 +1492,7 @@ static int m66592_start(struct usb_gadget_driver *driver,
goto error; goto error;
} }
retval = bind(&m66592->gadget); retval = bind(&m66592->gadget, driver);
if (retval) { if (retval) {
pr_err("bind to driver error (%d)\n", retval); pr_err("bind to driver error (%d)\n", retval);
device_del(&m66592->gadget.dev); device_del(&m66592->gadget.dev);

View File

@ -1269,7 +1269,7 @@ static int mv_udc_pullup(struct usb_gadget *gadget, int is_on)
} }
static int mv_udc_start(struct usb_gadget_driver *driver, static int mv_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int mv_udc_stop(struct usb_gadget_driver *driver); static int mv_udc_stop(struct usb_gadget_driver *driver);
/* device controller usb_gadget_ops structure */ /* device controller usb_gadget_ops structure */
static const struct usb_gadget_ops mv_ops = { static const struct usb_gadget_ops mv_ops = {
@ -1374,7 +1374,7 @@ static void stop_activity(struct mv_udc *udc, struct usb_gadget_driver *driver)
} }
static int mv_udc_start(struct usb_gadget_driver *driver, static int mv_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct mv_udc *udc = the_controller; struct mv_udc *udc = the_controller;
int retval = 0; int retval = 0;
@ -1399,7 +1399,7 @@ static int mv_udc_start(struct usb_gadget_driver *driver,
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
retval = bind(&udc->gadget); retval = bind(&udc->gadget, driver);
if (retval) { if (retval) {
dev_err(&udc->dev->dev, "bind to driver %s --> %d\n", dev_err(&udc->dev->dev, "bind to driver %s --> %d\n",
driver->driver.name, retval); driver->driver.name, retval);

View File

@ -1308,7 +1308,7 @@ static int omap_pullup(struct usb_gadget *gadget, int is_on)
} }
static int omap_udc_start(struct usb_gadget_driver *driver, static int omap_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int omap_udc_stop(struct usb_gadget_driver *driver); static int omap_udc_stop(struct usb_gadget_driver *driver);
static struct usb_gadget_ops omap_gadget_ops = { static struct usb_gadget_ops omap_gadget_ops = {
@ -2040,7 +2040,7 @@ static inline int machine_without_vbus_sense(void)
} }
static int omap_udc_start(struct usb_gadget_driver *driver, static int omap_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
int status = -ENODEV; int status = -ENODEV;
struct omap_ep *ep; struct omap_ep *ep;
@ -2082,7 +2082,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
if (udc->dc_clk != NULL) if (udc->dc_clk != NULL)
omap_udc_enable_clock(1); omap_udc_enable_clock(1);
status = bind(&udc->gadget); status = bind(&udc->gadget, driver);
if (status) { if (status) {
DBG("bind to %s --> %d\n", driver->driver.name, status); DBG("bind to %s --> %d\n", driver->driver.name, status);
udc->gadget.dev.driver = NULL; udc->gadget.dev.driver = NULL;

View File

@ -1236,7 +1236,7 @@ static int pch_udc_pcd_vbus_draw(struct usb_gadget *gadget, unsigned int mA)
} }
static int pch_udc_start(struct usb_gadget_driver *driver, static int pch_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int pch_udc_stop(struct usb_gadget_driver *driver); static int pch_udc_stop(struct usb_gadget_driver *driver);
static const struct usb_gadget_ops pch_udc_ops = { static const struct usb_gadget_ops pch_udc_ops = {
.get_frame = pch_udc_pcd_get_frame, .get_frame = pch_udc_pcd_get_frame,
@ -2982,7 +2982,7 @@ static int init_dma_pools(struct pch_udc_dev *dev)
} }
static int pch_udc_start(struct usb_gadget_driver *driver, static int pch_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct pch_udc_dev *dev = pch_udc; struct pch_udc_dev *dev = pch_udc;
int retval; int retval;
@ -3006,7 +3006,7 @@ static int pch_udc_start(struct usb_gadget_driver *driver,
dev->gadget.dev.driver = &driver->driver; dev->gadget.dev.driver = &driver->driver;
/* Invoke the bind routine of the gadget driver */ /* Invoke the bind routine of the gadget driver */
retval = bind(&dev->gadget); retval = bind(&dev->gadget, driver);
if (retval) { if (retval) {
dev_err(&dev->pdev->dev, "%s: binding to %s returning %d\n", dev_err(&dev->pdev->dev, "%s: binding to %s returning %d\n",

View File

@ -999,7 +999,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
} }
static int pxa25x_start(struct usb_gadget_driver *driver, static int pxa25x_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int pxa25x_stop(struct usb_gadget_driver *driver); static int pxa25x_stop(struct usb_gadget_driver *driver);
static const struct usb_gadget_ops pxa25x_udc_ops = { static const struct usb_gadget_ops pxa25x_udc_ops = {
@ -1257,7 +1257,7 @@ static void udc_enable (struct pxa25x_udc *dev)
* the driver might get unbound. * the driver might get unbound.
*/ */
static int pxa25x_start(struct usb_gadget_driver *driver, static int pxa25x_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct pxa25x_udc *dev = the_controller; struct pxa25x_udc *dev = the_controller;
int retval; int retval;
@ -1285,7 +1285,7 @@ fail:
dev->gadget.dev.driver = NULL; dev->gadget.dev.driver = NULL;
return retval; return retval;
} }
retval = bind(&dev->gadget); retval = bind(&dev->gadget, driver);
if (retval) { if (retval) {
DMSG("bind to driver %s --> error %d\n", DMSG("bind to driver %s --> error %d\n",
driver->driver.name, retval); driver->driver.name, retval);

View File

@ -1672,7 +1672,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
} }
static int pxa27x_udc_start(struct usb_gadget_driver *driver, static int pxa27x_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int pxa27x_udc_stop(struct usb_gadget_driver *driver); static int pxa27x_udc_stop(struct usb_gadget_driver *driver);
static const struct usb_gadget_ops pxa_udc_ops = { static const struct usb_gadget_ops pxa_udc_ops = {
@ -1803,7 +1803,7 @@ static void udc_enable(struct pxa_udc *udc)
* Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise
*/ */
static int pxa27x_udc_start(struct usb_gadget_driver *driver, static int pxa27x_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct pxa_udc *udc = the_controller; struct pxa_udc *udc = the_controller;
int retval; int retval;
@ -1826,7 +1826,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
dev_err(udc->dev, "device_add error %d\n", retval); dev_err(udc->dev, "device_add error %d\n", retval);
goto add_fail; goto add_fail;
} }
retval = bind(&udc->gadget); retval = bind(&udc->gadget, driver);
if (retval) { if (retval) {
dev_err(udc->dev, "bind to driver %s --> error %d\n", dev_err(udc->dev, "bind to driver %s --> error %d\n",
driver->driver.name, retval); driver->driver.name, retval);

View File

@ -1539,7 +1539,7 @@ static int s3c2410_vbus_draw(struct usb_gadget *_gadget, unsigned ma)
} }
static int s3c2410_udc_start(struct usb_gadget_driver *driver, static int s3c2410_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int s3c2410_udc_stop(struct usb_gadget_driver *driver); static int s3c2410_udc_stop(struct usb_gadget_driver *driver);
static const struct usb_gadget_ops s3c2410_ops = { static const struct usb_gadget_ops s3c2410_ops = {
@ -1665,7 +1665,7 @@ static void s3c2410_udc_enable(struct s3c2410_udc *dev)
} }
static int s3c2410_udc_start(struct usb_gadget_driver *driver, static int s3c2410_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct s3c2410_udc *udc = the_controller; struct s3c2410_udc *udc = the_controller;
int retval; int retval;
@ -1705,7 +1705,7 @@ static int s3c2410_udc_start(struct usb_gadget_driver *driver,
dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n", dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n",
driver->driver.name); driver->driver.name);
retval = bind(&udc->gadget); retval = bind(&udc->gadget, driver);
if (retval) { if (retval) {
device_del(&udc->gadget.dev); device_del(&udc->gadget.dev);
goto register_error; goto register_error;

View File

@ -118,7 +118,7 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
*/ */
static inline int usb_gadget_start(struct usb_gadget *gadget, static inline int usb_gadget_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver, struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *)) int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
return gadget->ops->start(driver, bind); return gadget->ops->start(driver, bind);
} }
@ -338,7 +338,7 @@ found:
udc->dev.driver = &driver->driver; udc->dev.driver = &driver->driver;
if (udc_is_newstyle(udc)) { if (udc_is_newstyle(udc)) {
ret = driver->bind(udc->gadget); ret = driver->bind(udc->gadget, driver);
if (ret) if (ret)
goto err1; goto err1;
ret = usb_gadget_udc_start(udc->gadget, driver); ret = usb_gadget_udc_start(udc->gadget, driver);

View File

@ -303,6 +303,7 @@ struct usb_composite_driver {
/* global suspend hooks */ /* global suspend hooks */
void (*suspend)(struct usb_composite_dev *); void (*suspend)(struct usb_composite_dev *);
void (*resume)(struct usb_composite_dev *); void (*resume)(struct usb_composite_dev *);
struct usb_gadget_driver gadget_driver;
}; };
extern int usb_composite_probe(struct usb_composite_driver *driver); extern int usb_composite_probe(struct usb_composite_driver *driver);

View File

@ -474,7 +474,8 @@ struct usb_gadget_ops {
/* Those two are deprecated */ /* Those two are deprecated */
int (*start)(struct usb_gadget_driver *, int (*start)(struct usb_gadget_driver *,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *,
struct usb_gadget_driver *driver));
int (*stop)(struct usb_gadget_driver *); int (*stop)(struct usb_gadget_driver *);
}; };
@ -821,7 +822,8 @@ 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 max_speed; enum usb_device_speed max_speed;
int (*bind)(struct usb_gadget *gadget); int (*bind)(struct usb_gadget *gadget,
struct usb_gadget_driver *driver);
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 *);