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

usb: gadget: move bind() callback back to struct usb_gadget_driver

This partly reverts 07a18bd7 ("usb gadget: don't save bind callback in
struct usb_composite_driver") and fixes new drivers. The section missmatch
problems was solved by whitelisting bind callback in modpost.
Acked-by: NMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 03e42bd5
...@@ -1585,6 +1585,7 @@ composite_resume(struct usb_gadget *gadget) ...@@ -1585,6 +1585,7 @@ composite_resume(struct usb_gadget *gadget)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static struct usb_gadget_driver composite_driver = { static struct usb_gadget_driver composite_driver = {
.bind = composite_bind,
.unbind = composite_unbind, .unbind = composite_unbind,
.setup = composite_setup, .setup = composite_setup,
...@@ -1631,7 +1632,7 @@ int usb_composite_probe(struct usb_composite_driver *driver) ...@@ -1631,7 +1632,7 @@ int usb_composite_probe(struct usb_composite_driver *driver)
composite_driver.max_speed = driver->max_speed; composite_driver.max_speed = driver->max_speed;
composite = driver; composite = driver;
return usb_gadget_probe_driver(&composite_driver, composite_bind); return usb_gadget_probe_driver(&composite_driver);
} }
/** /**
......
...@@ -405,6 +405,7 @@ static int dbgp_setup(struct usb_gadget *gadget, ...@@ -405,6 +405,7 @@ static int dbgp_setup(struct usb_gadget *gadget,
static __refdata struct usb_gadget_driver dbgp_driver = { static __refdata struct usb_gadget_driver dbgp_driver = {
.function = "dbgp", .function = "dbgp",
.max_speed = USB_SPEED_HIGH, .max_speed = USB_SPEED_HIGH,
.bind = dbgp_bind,
.unbind = dbgp_unbind, .unbind = dbgp_unbind,
.setup = dbgp_setup, .setup = dbgp_setup,
.disconnect = dbgp_disconnect, .disconnect = dbgp_disconnect,
...@@ -416,7 +417,7 @@ static __refdata struct usb_gadget_driver dbgp_driver = { ...@@ -416,7 +417,7 @@ static __refdata struct usb_gadget_driver dbgp_driver = {
static int __init dbgp_init(void) static int __init dbgp_init(void)
{ {
return usb_gadget_probe_driver(&dbgp_driver, dbgp_bind); return usb_gadget_probe_driver(&dbgp_driver);
} }
static void __exit dbgp_exit(void) static void __exit dbgp_exit(void)
......
...@@ -3606,6 +3606,7 @@ static void fsg_resume(struct usb_gadget *gadget) ...@@ -3606,6 +3606,7 @@ static void fsg_resume(struct usb_gadget *gadget)
static __refdata struct usb_gadget_driver fsg_driver = { static __refdata struct usb_gadget_driver fsg_driver = {
.max_speed = USB_SPEED_SUPER, .max_speed = USB_SPEED_SUPER,
.function = (char *) fsg_string_product, .function = (char *) fsg_string_product,
.bind = fsg_bind,
.unbind = fsg_unbind, .unbind = fsg_unbind,
.disconnect = fsg_disconnect, .disconnect = fsg_disconnect,
.setup = fsg_setup, .setup = fsg_setup,
...@@ -3653,7 +3654,8 @@ static int __init fsg_init(void) ...@@ -3653,7 +3654,8 @@ static int __init fsg_init(void)
if ((rc = fsg_alloc()) != 0) if ((rc = fsg_alloc()) != 0)
return rc; return rc;
fsg = the_fsg; fsg = the_fsg;
if ((rc = usb_gadget_probe_driver(&fsg_driver, fsg_bind)) != 0) rc = usb_gadget_probe_driver(&fsg_driver);
if (rc != 0)
kref_put(&fsg->ref, fsg_release); kref_put(&fsg->ref, fsg_release);
return rc; return rc;
} }
......
...@@ -1758,6 +1758,7 @@ gadgetfs_suspend (struct usb_gadget *gadget) ...@@ -1758,6 +1758,7 @@ gadgetfs_suspend (struct usb_gadget *gadget)
static struct usb_gadget_driver gadgetfs_driver = { static struct usb_gadget_driver gadgetfs_driver = {
.function = (char *) driver_desc, .function = (char *) driver_desc,
.bind = gadgetfs_bind,
.unbind = gadgetfs_unbind, .unbind = gadgetfs_unbind,
.setup = gadgetfs_setup, .setup = gadgetfs_setup,
.disconnect = gadgetfs_disconnect, .disconnect = gadgetfs_disconnect,
...@@ -1780,6 +1781,7 @@ static int gadgetfs_probe (struct usb_gadget *gadget) ...@@ -1780,6 +1781,7 @@ static int gadgetfs_probe (struct usb_gadget *gadget)
static struct usb_gadget_driver probe_driver = { static struct usb_gadget_driver probe_driver = {
.max_speed = USB_SPEED_HIGH, .max_speed = USB_SPEED_HIGH,
.bind = gadgetfs_probe,
.unbind = gadgetfs_nop, .unbind = gadgetfs_nop,
.setup = (void *)gadgetfs_nop, .setup = (void *)gadgetfs_nop,
.disconnect = gadgetfs_nop, .disconnect = gadgetfs_nop,
...@@ -1893,7 +1895,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) ...@@ -1893,7 +1895,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
gadgetfs_driver.max_speed = USB_SPEED_HIGH; gadgetfs_driver.max_speed = USB_SPEED_HIGH;
else else
gadgetfs_driver.max_speed = USB_SPEED_FULL; gadgetfs_driver.max_speed = USB_SPEED_FULL;
value = usb_gadget_probe_driver(&gadgetfs_driver, gadgetfs_bind);
value = usb_gadget_probe_driver(&gadgetfs_driver);
if (value != 0) { if (value != 0) {
kfree (dev->buf); kfree (dev->buf);
dev->buf = NULL; dev->buf = NULL;
...@@ -2032,7 +2035,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent) ...@@ -2032,7 +2035,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
return -ESRCH; return -ESRCH;
/* fake probe to determine $CHIP */ /* fake probe to determine $CHIP */
(void) usb_gadget_probe_driver(&probe_driver, gadgetfs_probe); usb_gadget_probe_driver(&probe_driver);
if (!CHIP) if (!CHIP)
return -ENODEV; return -ENODEV;
......
...@@ -311,13 +311,12 @@ EXPORT_SYMBOL_GPL(usb_del_gadget_udc); ...@@ -311,13 +311,12 @@ EXPORT_SYMBOL_GPL(usb_del_gadget_udc);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
int usb_gadget_probe_driver(struct usb_gadget_driver *driver, int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
int (*bind)(struct usb_gadget *))
{ {
struct usb_udc *udc = NULL; struct usb_udc *udc = NULL;
int ret; int ret;
if (!driver || !bind || !driver->setup) if (!driver || !driver->bind || !driver->setup)
return -EINVAL; return -EINVAL;
mutex_lock(&udc_lock); mutex_lock(&udc_lock);
...@@ -339,7 +338,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, ...@@ -339,7 +338,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
udc->dev.driver = &driver->driver; udc->dev.driver = &driver->driver;
if (udc_is_newstyle(udc)) { if (udc_is_newstyle(udc)) {
ret = bind(udc->gadget); ret = driver->bind(udc->gadget);
if (ret) if (ret)
goto err1; goto err1;
ret = usb_gadget_udc_start(udc->gadget, driver); ret = usb_gadget_udc_start(udc->gadget, driver);
...@@ -350,7 +349,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, ...@@ -350,7 +349,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
usb_gadget_connect(udc->gadget); usb_gadget_connect(udc->gadget);
} else { } else {
ret = usb_gadget_start(udc->gadget, driver, bind); ret = usb_gadget_start(udc->gadget, driver, driver->bind);
if (ret) if (ret)
goto err1; goto err1;
......
...@@ -766,6 +766,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) ...@@ -766,6 +766,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
* when the host is disconnected. May be called in_interrupt; this * when the host is disconnected. May be called in_interrupt; this
* may not sleep. Some devices can't detect disconnect, so this might * may not sleep. Some devices can't detect disconnect, so this might
* not be called except as part of controller shutdown. * not be called except as part of controller shutdown.
* @bind: the driver's bind callback
* @unbind: Invoked when the driver is unbound from a gadget, * @unbind: Invoked when the driver is unbound from a gadget,
* usually from rmmod (after a disconnect is reported). * usually from rmmod (after a disconnect is reported).
* Called in a context that permits sleeping. * Called in a context that permits sleeping.
...@@ -820,6 +821,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) ...@@ -820,6 +821,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 max_speed; enum usb_device_speed max_speed;
int (*bind)(struct usb_gadget *gadget);
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 *);
...@@ -845,7 +847,6 @@ struct usb_gadget_driver { ...@@ -845,7 +847,6 @@ struct usb_gadget_driver {
/** /**
* usb_gadget_probe_driver - probe a gadget driver * usb_gadget_probe_driver - probe a gadget driver
* @driver: the driver being registered * @driver: the driver being registered
* @bind: the driver's bind callback
* Context: can sleep * Context: can sleep
* *
* Call this in your gadget driver's module initialization function, * Call this in your gadget driver's module initialization function,
...@@ -854,8 +855,7 @@ struct usb_gadget_driver { ...@@ -854,8 +855,7 @@ struct usb_gadget_driver {
* registration call returns. It's expected that the @bind() function will * registration call returns. It's expected that the @bind() function will
* be in init sections. * be in init sections.
*/ */
int usb_gadget_probe_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 * usb_gadget_unregister_driver - unregister a gadget driver
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册