diff options
author | Felipe Balbi <balbi@ti.com> | 2013-01-24 10:36:33 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-01-24 21:11:28 +0200 |
commit | 8de94fffad1b471550645965888d7aaae0680cef (patch) | |
tree | 00000da7af4ec71b11c7d1c7886f4ae59d5a1e1d /drivers/usb/gadget | |
parent | 45005f6927d98d9a3364287a6e9faca7121cc8f1 (diff) | |
download | blackbird-op-linux-8de94fffad1b471550645965888d7aaae0680cef.tar.gz blackbird-op-linux-8de94fffad1b471550645965888d7aaae0680cef.zip |
usb: gadget: fusb300_udc: convert to udc_start/udc_stop
Mechanical change making use of the new (can we
still call it new ?) interface for registering
UDC drivers.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/fusb300_udc.c | 65 | ||||
-rw-r--r-- | drivers/usb/gadget/fusb300_udc.h | 2 |
2 files changed, 20 insertions, 47 deletions
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index 72cd5e6719db..8c2372fa294f 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c @@ -1308,65 +1308,28 @@ static void init_controller(struct fusb300 *fusb300) iowrite32(0xcfffff9f, fusb300->reg + FUSB300_OFFSET_IGER1); } /*------------------------------------------------------------------------*/ -static struct fusb300 *the_controller; - -static int fusb300_udc_start(struct usb_gadget_driver *driver, - int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) +static int fusb300_udc_start(struct usb_gadget *g, + struct usb_gadget_driver *driver) { - struct fusb300 *fusb300 = the_controller; - int retval; - - if (!driver - || driver->max_speed < USB_SPEED_FULL - || !bind - || !driver->setup) - return -EINVAL; - - if (!fusb300) - return -ENODEV; - - if (fusb300->driver) - return -EBUSY; + struct fusb300 *fusb300 = to_fusb300(g); /* hook up the driver */ driver->driver.bus = NULL; fusb300->driver = driver; fusb300->gadget.dev.driver = &driver->driver; - retval = device_add(&fusb300->gadget.dev); - if (retval) { - pr_err("device_add error (%d)\n", retval); - goto error; - } - - retval = bind(&fusb300->gadget, driver); - if (retval) { - pr_err("bind to driver error (%d)\n", retval); - device_del(&fusb300->gadget.dev); - goto error; - } - return 0; - -error: - fusb300->driver = NULL; - fusb300->gadget.dev.driver = NULL; - - return retval; } -static int fusb300_udc_stop(struct usb_gadget_driver *driver) +static int fusb300_udc_stop(struct usb_gadget *g, + struct usb_gadget_driver *driver) { - struct fusb300 *fusb300 = the_controller; - - if (driver != fusb300->driver || !driver->unbind) - return -EINVAL; + struct fusb300 *fusb300 = to_fusb300(g); driver->unbind(&fusb300->gadget); fusb300->gadget.dev.driver = NULL; init_controller(fusb300); - device_del(&fusb300->gadget.dev); fusb300->driver = NULL; return 0; @@ -1380,8 +1343,8 @@ static int fusb300_udc_pullup(struct usb_gadget *_gadget, int is_active) static struct usb_gadget_ops fusb300_gadget_ops = { .pullup = fusb300_udc_pullup, - .start = fusb300_udc_start, - .stop = fusb300_udc_stop, + .udc_start = fusb300_udc_start, + .udc_stop = fusb300_udc_stop, }; static int __exit fusb300_remove(struct platform_device *pdev) @@ -1505,8 +1468,6 @@ static int __init fusb300_probe(struct platform_device *pdev) fusb300->gadget.ep0 = &fusb300->ep[0]->ep; INIT_LIST_HEAD(&fusb300->gadget.ep0->ep_list); - the_controller = fusb300; - fusb300->ep0_req = fusb300_alloc_request(&fusb300->ep[0]->ep, GFP_KERNEL); if (fusb300->ep0_req == NULL) @@ -1517,9 +1478,19 @@ static int __init fusb300_probe(struct platform_device *pdev) if (ret) goto err_add_udc; + ret = device_add(&fusb300->gadget.dev); + if (ret) { + pr_err("device_add error (%d)\n", ret); + goto err_add_device; + } + dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); return 0; + +err_add_device: + usb_del_gadget_udc(&fusb300->gadget); + err_add_udc: fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req); diff --git a/drivers/usb/gadget/fusb300_udc.h b/drivers/usb/gadget/fusb300_udc.h index 542cd83cc806..6ba444ae8dd5 100644 --- a/drivers/usb/gadget/fusb300_udc.h +++ b/drivers/usb/gadget/fusb300_udc.h @@ -673,4 +673,6 @@ struct fusb300 { u8 reenum; /* if re-enumeration */ }; +#define to_fusb300(g) (container_of((g), struct fusb300, gadget)) + #endif |