Skip to content

Commit

Permalink
usb: gadget: r8a66597-udc: fix for udc-newstyle
Browse files Browse the repository at this point in the history
The udc-newstyle needs device_register in probe() of platform_device.
If it doesn't call, kernel panic happens in the sysfs_create_dir() when
we run modprobe a gadget driver.

[ balbi@ti.com : fix compile warning introduced by this patch ]

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Yoshihiro Shimoda authored and Greg Kroah-Hartman committed Nov 14, 2011
1 parent 0de174b commit b8cbbf8
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions drivers/usb/gadget/r8a66597-udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,6 @@ static int r8a66597_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
int retval;

if (!driver
|| driver->speed != USB_SPEED_HIGH
Expand All @@ -1752,16 +1751,7 @@ static int r8a66597_start(struct usb_gadget *gadget,
return -ENODEV;

/* hook up the driver */
driver->driver.bus = NULL;
r8a66597->driver = driver;
r8a66597->gadget.dev.driver = &driver->driver;

retval = device_add(&r8a66597->gadget.dev);
if (retval) {
dev_err(r8a66597_to_dev(r8a66597), "device_add error (%d)\n",
retval);
goto error;
}

init_controller(r8a66597);
r8a66597_bset(r8a66597, VBSE, INTENB0);
Expand All @@ -1775,12 +1765,6 @@ static int r8a66597_start(struct usb_gadget *gadget,
}

return 0;

error:
r8a66597->driver = NULL;
r8a66597->gadget.dev.driver = NULL;

return retval;
}

static int r8a66597_stop(struct usb_gadget *gadget,
Expand All @@ -1794,7 +1778,6 @@ static int r8a66597_stop(struct usb_gadget *gadget,
disable_controller(r8a66597);
spin_unlock_irqrestore(&r8a66597->lock, flags);

device_del(&r8a66597->gadget.dev);
r8a66597->driver = NULL;
return 0;
}
Expand Down Expand Up @@ -1845,6 +1828,7 @@ static int __exit r8a66597_remove(struct platform_device *pdev)
clk_put(r8a66597->clk);
}
#endif
device_unregister(&r8a66597->gadget.dev);
kfree(r8a66597);
return 0;
}
Expand Down Expand Up @@ -1924,13 +1908,17 @@ static int __init r8a66597_probe(struct platform_device *pdev)
r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW;

r8a66597->gadget.ops = &r8a66597_gadget_ops;
device_initialize(&r8a66597->gadget.dev);
dev_set_name(&r8a66597->gadget.dev, "gadget");
r8a66597->gadget.is_dualspeed = 1;
r8a66597->gadget.dev.parent = &pdev->dev;
r8a66597->gadget.dev.dma_mask = pdev->dev.dma_mask;
r8a66597->gadget.dev.release = pdev->dev.release;
r8a66597->gadget.name = udc_name;
ret = device_register(&r8a66597->gadget.dev);
if (ret < 0) {
dev_err(&pdev->dev, "device_register failed\n");
goto clean_up;
}

init_timer(&r8a66597->timer);
r8a66597->timer.function = r8a66597_timer;
Expand All @@ -1945,7 +1933,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "cannot get clock \"%s\"\n",
clk_name);
ret = PTR_ERR(r8a66597->clk);
goto clean_up;
goto clean_up_dev;
}
clk_enable(r8a66597->clk);
}
Expand Down Expand Up @@ -2014,7 +2002,9 @@ static int __init r8a66597_probe(struct platform_device *pdev)
clk_disable(r8a66597->clk);
clk_put(r8a66597->clk);
}
clean_up_dev:
#endif
device_unregister(&r8a66597->gadget.dev);
clean_up:
if (r8a66597) {
if (r8a66597->sudmac_reg)
Expand Down

0 comments on commit b8cbbf8

Please sign in to comment.