Commit 7597a49b authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: s3c2410: 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 s3c2410 mistake.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 56aa45ad
...@@ -1669,7 +1669,6 @@ static int s3c2410_udc_start(struct usb_gadget *g, ...@@ -1669,7 +1669,6 @@ static int s3c2410_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver) struct usb_gadget_driver *driver)
{ {
struct s3c2410_udc *udc = to_s3c2410(g) struct s3c2410_udc *udc = to_s3c2410(g)
int retval;
dprintk(DEBUG_NORMAL, "%s() '%s'\n", __func__, driver->driver.name); dprintk(DEBUG_NORMAL, "%s() '%s'\n", __func__, driver->driver.name);
...@@ -1677,22 +1676,10 @@ static int s3c2410_udc_start(struct usb_gadget *g, ...@@ -1677,22 +1676,10 @@ static int s3c2410_udc_start(struct usb_gadget *g,
udc->driver = driver; udc->driver = driver;
udc->gadget.dev.driver = &driver->driver; udc->gadget.dev.driver = &driver->driver;
/* Bind the driver */
retval = device_add(&udc->gadget.dev);
if (retval) {
dev_err(&udc->gadget.dev, "Error in device_add() : %d\n", retval);
goto register_error;
}
/* Enable udc */ /* Enable udc */
s3c2410_udc_enable(udc); s3c2410_udc_enable(udc);
return 0; return 0;
register_error:
udc->driver = NULL;
udc->gadget.dev.driver = NULL;
return retval;
} }
static int s3c2410_udc_stop(struct usb_gadget *g, static int s3c2410_udc_stop(struct usb_gadget *g,
...@@ -1700,7 +1687,6 @@ static int s3c2410_udc_stop(struct usb_gadget *g, ...@@ -1700,7 +1687,6 @@ static int s3c2410_udc_stop(struct usb_gadget *g,
{ {
struct s3c2410_udc *udc = to_s3c2410(g); struct s3c2410_udc *udc = to_s3c2410(g);
device_del(&udc->gadget.dev);
udc->driver = NULL; udc->driver = NULL;
/* Disable udc */ /* Disable udc */
...@@ -1842,6 +1828,13 @@ static int s3c2410_udc_probe(struct platform_device *pdev) ...@@ -1842,6 +1828,13 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
udc->gadget.dev.parent = &pdev->dev; udc->gadget.dev.parent = &pdev->dev;
udc->gadget.dev.dma_mask = pdev->dev.dma_mask; udc->gadget.dev.dma_mask = pdev->dev.dma_mask;
/* Bind the driver */
retval = device_add(&udc->gadget.dev);
if (retval) {
dev_err(&udc->gadget.dev, "Error in device_add() : %d\n", retval);
goto err_device_add;
}
the_controller = udc; the_controller = udc;
platform_set_drvdata(pdev, udc); platform_set_drvdata(pdev, udc);
...@@ -1930,6 +1923,8 @@ static int s3c2410_udc_probe(struct platform_device *pdev) ...@@ -1930,6 +1923,8 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
err_int: err_int:
free_irq(IRQ_USBD, udc); free_irq(IRQ_USBD, udc);
err_map: err_map:
device_unregister(&udc->gadget.dev);
err_device_add:
iounmap(base_addr); iounmap(base_addr);
err_mem: err_mem:
release_mem_region(rsrc_start, rsrc_len); release_mem_region(rsrc_start, rsrc_len);
...@@ -1947,10 +1942,11 @@ static int s3c2410_udc_remove(struct platform_device *pdev) ...@@ -1947,10 +1942,11 @@ static int s3c2410_udc_remove(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s()\n", __func__); dev_dbg(&pdev->dev, "%s()\n", __func__);
usb_del_gadget_udc(&udc->gadget);
if (udc->driver) if (udc->driver)
return -EBUSY; return -EBUSY;
usb_del_gadget_udc(&udc->gadget);
device_unregister(&udc->gadget.dev);
debugfs_remove(udc->regs_info); debugfs_remove(udc->regs_info);
if (udc_info && !udc_info->udc_command && if (udc_info && !udc_info->udc_command &&
......
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