Skip to content

Commit

Permalink
usb: gadget: s3c2410: fix gadget->dev registration
Browse files Browse the repository at this point in the history
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: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Felipe Balbi committed Mar 4, 2013
1 parent 56aa45a commit 7597a49
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions drivers/usb/gadget/s3c2410_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1669,38 +1669,24 @@ static int s3c2410_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct s3c2410_udc *udc = to_s3c2410(g)
int retval;

dprintk(DEBUG_NORMAL, "%s() '%s'\n", __func__, driver->driver.name);

/* Hook the driver */
udc->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 */
s3c2410_udc_enable(udc);

return 0;

register_error:
udc->driver = NULL;
udc->gadget.dev.driver = NULL;
return retval;
}

static int s3c2410_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct s3c2410_udc *udc = to_s3c2410(g);

device_del(&udc->gadget.dev);
udc->driver = NULL;

/* Disable udc */
Expand Down Expand Up @@ -1842,6 +1828,13 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
udc->gadget.dev.parent = &pdev->dev;
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;
platform_set_drvdata(pdev, udc);

Expand Down Expand Up @@ -1930,6 +1923,8 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
err_int:
free_irq(IRQ_USBD, udc);
err_map:
device_unregister(&udc->gadget.dev);
err_device_add:
iounmap(base_addr);
err_mem:
release_mem_region(rsrc_start, rsrc_len);
Expand All @@ -1947,10 +1942,11 @@ static int s3c2410_udc_remove(struct platform_device *pdev)

dev_dbg(&pdev->dev, "%s()\n", __func__);

usb_del_gadget_udc(&udc->gadget);
if (udc->driver)
return -EBUSY;

usb_del_gadget_udc(&udc->gadget);
device_unregister(&udc->gadget.dev);
debugfs_remove(udc->regs_info);

if (udc_info && !udc_info->udc_command &&
Expand Down

0 comments on commit 7597a49

Please sign in to comment.