Commit bc530a72 authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: imx_udc: 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 imx_udc mistake.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 9992a997
...@@ -1334,27 +1334,18 @@ static int imx_udc_start(struct usb_gadget *gadget, ...@@ -1334,27 +1334,18 @@ static int imx_udc_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver) struct usb_gadget_driver *driver)
{ {
struct imx_udc_struct *imx_usb; struct imx_udc_struct *imx_usb;
int retval;
imx_usb = container_of(gadget, struct imx_udc_struct, gadget); imx_usb = container_of(gadget, struct imx_udc_struct, gadget);
/* first hook up the driver ... */ /* first hook up the driver ... */
imx_usb->driver = driver; imx_usb->driver = driver;
imx_usb->gadget.dev.driver = &driver->driver; imx_usb->gadget.dev.driver = &driver->driver;
retval = device_add(&imx_usb->gadget.dev);
if (retval)
goto fail;
D_INI(imx_usb->dev, "<%s> registered gadget driver '%s'\n", D_INI(imx_usb->dev, "<%s> registered gadget driver '%s'\n",
__func__, driver->driver.name); __func__, driver->driver.name);
imx_udc_enable(imx_usb); imx_udc_enable(imx_usb);
return 0; return 0;
fail:
imx_usb->driver = NULL;
imx_usb->gadget.dev.driver = NULL;
return retval;
} }
static int imx_udc_stop(struct usb_gadget *gadget, static int imx_udc_stop(struct usb_gadget *gadget,
...@@ -1370,8 +1361,6 @@ static int imx_udc_stop(struct usb_gadget *gadget, ...@@ -1370,8 +1361,6 @@ static int imx_udc_stop(struct usb_gadget *gadget,
imx_usb->gadget.dev.driver = NULL; imx_usb->gadget.dev.driver = NULL;
imx_usb->driver = NULL; imx_usb->driver = NULL;
device_del(&imx_usb->gadget.dev);
D_INI(imx_usb->dev, "<%s> unregistered gadget driver '%s'\n", D_INI(imx_usb->dev, "<%s> unregistered gadget driver '%s'\n",
__func__, driver->driver.name); __func__, driver->driver.name);
...@@ -1477,6 +1466,10 @@ static int __init imx_udc_probe(struct platform_device *pdev) ...@@ -1477,6 +1466,10 @@ static int __init imx_udc_probe(struct platform_device *pdev)
imx_usb->gadget.dev.parent = &pdev->dev; imx_usb->gadget.dev.parent = &pdev->dev;
imx_usb->gadget.dev.dma_mask = pdev->dev.dma_mask; imx_usb->gadget.dev.dma_mask = pdev->dev.dma_mask;
ret = device_add(&imx_usb->gadget.dev);
if (retval)
goto fail4;
platform_set_drvdata(pdev, imx_usb); platform_set_drvdata(pdev, imx_usb);
usb_init_data(imx_usb); usb_init_data(imx_usb);
...@@ -1488,9 +1481,11 @@ static int __init imx_udc_probe(struct platform_device *pdev) ...@@ -1488,9 +1481,11 @@ static int __init imx_udc_probe(struct platform_device *pdev)
ret = usb_add_gadget_udc(&pdev->dev, &imx_usb->gadget); ret = usb_add_gadget_udc(&pdev->dev, &imx_usb->gadget);
if (ret) if (ret)
goto fail4; goto fail5;
return 0; return 0;
fail5:
device_unregister(&imx_usb->gadget.dev);
fail4: fail4:
for (i = 0; i < IMX_USB_NB_EP + 1; i++) for (i = 0; i < IMX_USB_NB_EP + 1; i++)
free_irq(imx_usb->usbd_int[i], imx_usb); free_irq(imx_usb->usbd_int[i], imx_usb);
...@@ -1514,6 +1509,7 @@ static int __exit imx_udc_remove(struct platform_device *pdev) ...@@ -1514,6 +1509,7 @@ static int __exit imx_udc_remove(struct platform_device *pdev)
int i; int i;
usb_del_gadget_udc(&imx_usb->gadget); usb_del_gadget_udc(&imx_usb->gadget);
device_unregister(&imx_usb->gadget.dev);
imx_udc_disable(imx_usb); imx_udc_disable(imx_usb);
del_timer(&imx_usb->timer); del_timer(&imx_usb->timer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment