Commit b8cbbf80 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Greg Kroah-Hartman

usb: gadget: r8a66597-udc: fix for udc-newstyle

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: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0de174b5
...@@ -1742,7 +1742,6 @@ static int r8a66597_start(struct usb_gadget *gadget, ...@@ -1742,7 +1742,6 @@ static int r8a66597_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver) struct usb_gadget_driver *driver)
{ {
struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget); struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
int retval;
if (!driver if (!driver
|| driver->speed != USB_SPEED_HIGH || driver->speed != USB_SPEED_HIGH
...@@ -1752,16 +1751,7 @@ static int r8a66597_start(struct usb_gadget *gadget, ...@@ -1752,16 +1751,7 @@ static int r8a66597_start(struct usb_gadget *gadget,
return -ENODEV; return -ENODEV;
/* hook up the driver */ /* hook up the driver */
driver->driver.bus = NULL;
r8a66597->driver = driver; 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); init_controller(r8a66597);
r8a66597_bset(r8a66597, VBSE, INTENB0); r8a66597_bset(r8a66597, VBSE, INTENB0);
...@@ -1775,12 +1765,6 @@ static int r8a66597_start(struct usb_gadget *gadget, ...@@ -1775,12 +1765,6 @@ static int r8a66597_start(struct usb_gadget *gadget,
} }
return 0; return 0;
error:
r8a66597->driver = NULL;
r8a66597->gadget.dev.driver = NULL;
return retval;
} }
static int r8a66597_stop(struct usb_gadget *gadget, static int r8a66597_stop(struct usb_gadget *gadget,
...@@ -1794,7 +1778,6 @@ static int r8a66597_stop(struct usb_gadget *gadget, ...@@ -1794,7 +1778,6 @@ static int r8a66597_stop(struct usb_gadget *gadget,
disable_controller(r8a66597); disable_controller(r8a66597);
spin_unlock_irqrestore(&r8a66597->lock, flags); spin_unlock_irqrestore(&r8a66597->lock, flags);
device_del(&r8a66597->gadget.dev);
r8a66597->driver = NULL; r8a66597->driver = NULL;
return 0; return 0;
} }
...@@ -1845,6 +1828,7 @@ static int __exit r8a66597_remove(struct platform_device *pdev) ...@@ -1845,6 +1828,7 @@ static int __exit r8a66597_remove(struct platform_device *pdev)
clk_put(r8a66597->clk); clk_put(r8a66597->clk);
} }
#endif #endif
device_unregister(&r8a66597->gadget.dev);
kfree(r8a66597); kfree(r8a66597);
return 0; return 0;
} }
...@@ -1924,13 +1908,17 @@ static int __init r8a66597_probe(struct platform_device *pdev) ...@@ -1924,13 +1908,17 @@ static int __init r8a66597_probe(struct platform_device *pdev)
r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW;
r8a66597->gadget.ops = &r8a66597_gadget_ops; r8a66597->gadget.ops = &r8a66597_gadget_ops;
device_initialize(&r8a66597->gadget.dev);
dev_set_name(&r8a66597->gadget.dev, "gadget"); dev_set_name(&r8a66597->gadget.dev, "gadget");
r8a66597->gadget.is_dualspeed = 1; r8a66597->gadget.is_dualspeed = 1;
r8a66597->gadget.dev.parent = &pdev->dev; r8a66597->gadget.dev.parent = &pdev->dev;
r8a66597->gadget.dev.dma_mask = pdev->dev.dma_mask; r8a66597->gadget.dev.dma_mask = pdev->dev.dma_mask;
r8a66597->gadget.dev.release = pdev->dev.release; r8a66597->gadget.dev.release = pdev->dev.release;
r8a66597->gadget.name = udc_name; 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); init_timer(&r8a66597->timer);
r8a66597->timer.function = r8a66597_timer; r8a66597->timer.function = r8a66597_timer;
...@@ -1945,7 +1933,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) ...@@ -1945,7 +1933,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "cannot get clock \"%s\"\n", dev_err(&pdev->dev, "cannot get clock \"%s\"\n",
clk_name); clk_name);
ret = PTR_ERR(r8a66597->clk); ret = PTR_ERR(r8a66597->clk);
goto clean_up; goto clean_up_dev;
} }
clk_enable(r8a66597->clk); clk_enable(r8a66597->clk);
} }
...@@ -2014,7 +2002,9 @@ static int __init r8a66597_probe(struct platform_device *pdev) ...@@ -2014,7 +2002,9 @@ static int __init r8a66597_probe(struct platform_device *pdev)
clk_disable(r8a66597->clk); clk_disable(r8a66597->clk);
clk_put(r8a66597->clk); clk_put(r8a66597->clk);
} }
clean_up_dev:
#endif #endif
device_unregister(&r8a66597->gadget.dev);
clean_up: clean_up:
if (r8a66597) { if (r8a66597) {
if (r8a66597->sudmac_reg) if (r8a66597->sudmac_reg)
......
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