From 0f91349b89f37dfad7b77f7829a105b6a0f526ec Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 28 Jun 2011 16:33:47 +0300 Subject: usb: gadget: convert all users to the new udc infrastructure peripheral drivers are using usb_add_gadget()/usb_del_gadget() to register/unregister to the udc-core. The udc-core will take the first available gadget driver and attach function driver which is calling usb_gadget_register_driver(). This is the same behaviour we have right now. Only dummy_hcd was tested, the others were compiled tested. Cc: Alan Stern Cc: Anton Tikhomirov Cc: Ben Dooks Cc: Dan Carpenter Cc: Darius Augulis Cc: Eric Miao Cc: Jingoo Han Cc: Kukjin Kim Cc: Kuninori Morimoto Cc: Li Yang Cc: Michael Hennerich Acked-by: Mike Frysinger Cc: Nicolas Ferre Cc: Pavankumar Kondeti Cc: Roy Huang Cc: Russell King Cc: Toshiharu Okada Cc: Xiaochen Shen Cc: Yoshihiro Shimoda Cc: Yuan-Hsin Chen Cc: cxie4 Cc: linux-geode@lists.infradead.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_gadget.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 0a50a35e1853..728572cf709c 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1704,6 +1704,10 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) return 0; } +static int musb_gadget_start(struct usb_gadget_driver *driver, + int (*bind)(struct usb_gadget *)); +static int musb_gadget_stop(struct usb_gadget_driver *driver); + static const struct usb_gadget_ops musb_gadget_operations = { .get_frame = musb_gadget_get_frame, .wakeup = musb_gadget_wakeup, @@ -1711,6 +1715,8 @@ static const struct usb_gadget_ops musb_gadget_operations = { /* .vbus_session = musb_gadget_vbus_session, */ .vbus_draw = musb_gadget_vbus_draw, .pullup = musb_gadget_pullup, + .start = musb_gadget_start, + .stop = musb_gadget_stop, }; /* ----------------------------------------------------------------------- */ @@ -1835,7 +1841,16 @@ int __init musb_gadget_setup(struct musb *musb) if (status != 0) { put_device(&musb->g.dev); the_gadget = NULL; + return status; } + status = usb_add_gadget_udc(musb->controller, &musb->g); + if (status) + goto err; + + return 0; +err: + device_unregister(&musb->g.dev); + the_gadget = NULL; return status; } @@ -1844,6 +1859,7 @@ void musb_gadget_cleanup(struct musb *musb) if (musb != the_gadget) return; + usb_del_gadget_udc(&musb->g); device_unregister(&musb->g.dev); the_gadget = NULL; } @@ -1860,7 +1876,7 @@ void musb_gadget_cleanup(struct musb *musb) * @param bind the driver's bind function * @return <0 if error, 0 if everything is fine */ -int usb_gadget_probe_driver(struct usb_gadget_driver *driver, +static int musb_gadget_start(struct usb_gadget_driver *driver, int (*bind)(struct usb_gadget *)) { struct musb *musb = the_gadget; @@ -1962,7 +1978,6 @@ err1: err0: return retval; } -EXPORT_SYMBOL(usb_gadget_probe_driver); static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver) { @@ -2012,7 +2027,7 @@ static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver) * * @param driver the gadget driver to unregister */ -int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) +static int musb_gadget_stop(struct usb_gadget_driver *driver) { struct musb *musb = the_gadget; unsigned long flags; @@ -2071,8 +2086,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) return 0; } -EXPORT_SYMBOL(usb_gadget_unregister_driver); - /* ----------------------------------------------------------------------- */ -- cgit v1.2.3