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/gadget/atmel_usba_udc.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'drivers/usb/gadget/atmel_usba_udc.c') diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index db1a659702b..e6b970a2a29 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -1007,10 +1007,16 @@ usba_udc_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered) return 0; } +static int atmel_usba_start(struct usb_gadget_driver *driver, + int (*bind)(struct usb_gadget *)); +static int atmel_usba_stop(struct usb_gadget_driver *driver); + static const struct usb_gadget_ops usba_udc_ops = { .get_frame = usba_udc_get_frame, .wakeup = usba_udc_wakeup, .set_selfpowered = usba_udc_set_selfpowered, + .start = atmel_usba_start, + .stop = atmel_usba_stop, }; static struct usb_endpoint_descriptor usba_ep0_desc = { @@ -1789,7 +1795,7 @@ out: return IRQ_HANDLED; } -int usb_gadget_probe_driver(struct usb_gadget_driver *driver, +static int atmel_usba_start(struct usb_gadget_driver *driver, int (*bind)(struct usb_gadget *)) { struct usba_udc *udc = &the_udc; @@ -1842,9 +1848,8 @@ err_driver_bind: udc->gadget.dev.driver = NULL; return ret; } -EXPORT_SYMBOL(usb_gadget_probe_driver); -int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) +static int atmel_usba_stop(struct usb_gadget_driver *driver) { struct usba_udc *udc = &the_udc; unsigned long flags; @@ -1880,7 +1885,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) return 0; } -EXPORT_SYMBOL(usb_gadget_unregister_driver); static int __init usba_udc_probe(struct platform_device *pdev) { @@ -2021,12 +2025,24 @@ static int __init usba_udc_probe(struct platform_device *pdev) } } + ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget); + if (ret) + goto err_add_udc; + usba_init_debugfs(udc); for (i = 1; i < pdata->num_ep; i++) usba_ep_init_debugfs(udc, &usba_ep[i]); return 0; +err_add_udc: + if (gpio_is_valid(pdata->vbus_pin)) { + free_irq(gpio_to_irq(udc->vbus_pin), udc); + gpio_free(udc->vbus_pin); + } + + device_unregister(&udc->gadget.dev); + err_device_add: free_irq(irq, udc); err_request_irq: @@ -2053,6 +2069,8 @@ static int __exit usba_udc_remove(struct platform_device *pdev) udc = platform_get_drvdata(pdev); + usb_del_gadget_udc(&udc->gadget); + for (i = 1; i < pdata->num_ep; i++) usba_ep_cleanup_debugfs(&usba_ep[i]); usba_cleanup_debugfs(udc); -- cgit v1.2.3-18-g5258