diff options
author | Felipe Balbi <balbi@ti.com> | 2013-02-25 14:15:41 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-03-04 02:33:28 -0500 |
commit | 9992a9979fd463903e1a34b68d609441f36bafd4 (patch) | |
tree | c0fa064eea47065475a0f76d795331c9ac03d1a8 /drivers/usb/gadget/pxa25x_udc.c | |
parent | 7597a49b1e984bfb9930f832af963de1120d30e4 (diff) |
usb: gadget: pxa25x: fix gadget->dev registration
Whenever ->udc_start() gets called, gadget driver
has already being bound to the udc controller, which
means that gadget->dev had to be already initialized
and added to driver model.
This patch fixes pxa25x mistake.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/pxa25x_udc.c')
-rw-r--r-- | drivers/usb/gadget/pxa25x_udc.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 2bbcdce942dc..9aa9dd5168d8 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
@@ -1266,13 +1266,6 @@ static int pxa25x_udc_start(struct usb_gadget *g, | |||
1266 | dev->gadget.dev.driver = &driver->driver; | 1266 | dev->gadget.dev.driver = &driver->driver; |
1267 | dev->pullup = 1; | 1267 | dev->pullup = 1; |
1268 | 1268 | ||
1269 | retval = device_add (&dev->gadget.dev); | ||
1270 | if (retval) { | ||
1271 | dev->driver = NULL; | ||
1272 | dev->gadget.dev.driver = NULL; | ||
1273 | return retval; | ||
1274 | } | ||
1275 | |||
1276 | /* ... then enable host detection and ep0; and we're ready | 1269 | /* ... then enable host detection and ep0; and we're ready |
1277 | * for set_configuration as well as eventual disconnect. | 1270 | * for set_configuration as well as eventual disconnect. |
1278 | */ | 1271 | */ |
@@ -1331,7 +1324,6 @@ static int pxa25x_udc_stop(struct usb_gadget*g, | |||
1331 | dev->gadget.dev.driver = NULL; | 1324 | dev->gadget.dev.driver = NULL; |
1332 | dev->driver = NULL; | 1325 | dev->driver = NULL; |
1333 | 1326 | ||
1334 | device_del (&dev->gadget.dev); | ||
1335 | dump_state(dev); | 1327 | dump_state(dev); |
1336 | 1328 | ||
1337 | return 0; | 1329 | return 0; |
@@ -2146,6 +2138,13 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) | |||
2146 | dev->gadget.dev.parent = &pdev->dev; | 2138 | dev->gadget.dev.parent = &pdev->dev; |
2147 | dev->gadget.dev.dma_mask = pdev->dev.dma_mask; | 2139 | dev->gadget.dev.dma_mask = pdev->dev.dma_mask; |
2148 | 2140 | ||
2141 | retval = device_add(&dev->gadget.dev); | ||
2142 | if (retval) { | ||
2143 | dev->driver = NULL; | ||
2144 | dev->gadget.dev.driver = NULL; | ||
2145 | goto err_device_add; | ||
2146 | } | ||
2147 | |||
2149 | the_controller = dev; | 2148 | the_controller = dev; |
2150 | platform_set_drvdata(pdev, dev); | 2149 | platform_set_drvdata(pdev, dev); |
2151 | 2150 | ||
@@ -2196,6 +2195,8 @@ lubbock_fail0: | |||
2196 | free_irq(irq, dev); | 2195 | free_irq(irq, dev); |
2197 | #endif | 2196 | #endif |
2198 | err_irq1: | 2197 | err_irq1: |
2198 | device_unregister(&dev->gadget.dev); | ||
2199 | err_device_add: | ||
2199 | if (gpio_is_valid(dev->mach->gpio_pullup)) | 2200 | if (gpio_is_valid(dev->mach->gpio_pullup)) |
2200 | gpio_free(dev->mach->gpio_pullup); | 2201 | gpio_free(dev->mach->gpio_pullup); |
2201 | err_gpio_pullup: | 2202 | err_gpio_pullup: |
@@ -2217,10 +2218,11 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev) | |||
2217 | { | 2218 | { |
2218 | struct pxa25x_udc *dev = platform_get_drvdata(pdev); | 2219 | struct pxa25x_udc *dev = platform_get_drvdata(pdev); |
2219 | 2220 | ||
2220 | usb_del_gadget_udc(&dev->gadget); | ||
2221 | if (dev->driver) | 2221 | if (dev->driver) |
2222 | return -EBUSY; | 2222 | return -EBUSY; |
2223 | 2223 | ||
2224 | usb_del_gadget_udc(&dev->gadget); | ||
2225 | device_unregister(&dev->gadget.dev); | ||
2224 | dev->pullup = 0; | 2226 | dev->pullup = 0; |
2225 | pullup(dev); | 2227 | pullup(dev); |
2226 | 2228 | ||