usb: renesas_usbhs: fixup device_register timing
current renesas_usbhs is using new style udc_start/stop from
af1d7056a5
(usb: gadget: renesas: convert to new style).
But bind() function will fail if it was called before
device_register() (or device_add()).
This patch modifies this issue.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
5d193ce8f1
commit
f8eff0a061
1 changed files with 11 additions and 26 deletions
|
@ -751,53 +751,31 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget,
|
|||
struct usb_gadget_driver *driver)
|
||||
{
|
||||
struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
|
||||
struct usbhs_priv *priv;
|
||||
struct device *dev;
|
||||
int ret;
|
||||
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
|
||||
|
||||
if (!driver ||
|
||||
!driver->setup ||
|
||||
driver->speed != USB_SPEED_HIGH)
|
||||
return -EINVAL;
|
||||
|
||||
dev = usbhsg_gpriv_to_dev(gpriv);
|
||||
priv = usbhsg_gpriv_to_priv(gpriv);
|
||||
|
||||
/* first hook up the driver ... */
|
||||
gpriv->driver = driver;
|
||||
gpriv->gadget.dev.driver = &driver->driver;
|
||||
|
||||
ret = device_add(&gpriv->gadget.dev);
|
||||
if (ret) {
|
||||
dev_err(dev, "device_add error %d\n", ret);
|
||||
goto add_fail;
|
||||
}
|
||||
|
||||
return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD);
|
||||
|
||||
add_fail:
|
||||
gpriv->driver = NULL;
|
||||
gpriv->gadget.dev.driver = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usbhsg_gadget_stop(struct usb_gadget *gadget,
|
||||
struct usb_gadget_driver *driver)
|
||||
{
|
||||
struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
|
||||
struct usbhs_priv *priv;
|
||||
struct device *dev;
|
||||
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
|
||||
|
||||
if (!driver ||
|
||||
!driver->unbind)
|
||||
return -EINVAL;
|
||||
|
||||
dev = usbhsg_gpriv_to_dev(gpriv);
|
||||
priv = usbhsg_gpriv_to_priv(gpriv);
|
||||
|
||||
usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD);
|
||||
device_del(&gpriv->gadget.dev);
|
||||
gpriv->driver = NULL;
|
||||
|
||||
return 0;
|
||||
|
@ -876,12 +854,14 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
|
|||
/*
|
||||
* init gadget
|
||||
*/
|
||||
device_initialize(&gpriv->gadget.dev);
|
||||
dev_set_name(&gpriv->gadget.dev, "gadget");
|
||||
gpriv->gadget.dev.parent = dev;
|
||||
gpriv->gadget.name = "renesas_usbhs_udc";
|
||||
gpriv->gadget.ops = &usbhsg_gadget_ops;
|
||||
gpriv->gadget.is_dualspeed = 1;
|
||||
ret = device_register(&gpriv->gadget.dev);
|
||||
if (ret < 0)
|
||||
goto err_add_udc;
|
||||
|
||||
INIT_LIST_HEAD(&gpriv->gadget.ep_list);
|
||||
|
||||
|
@ -912,12 +892,15 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
|
|||
|
||||
ret = usb_add_gadget_udc(dev, &gpriv->gadget);
|
||||
if (ret)
|
||||
goto err_add_udc;
|
||||
goto err_register;
|
||||
|
||||
|
||||
dev_info(dev, "gadget probed\n");
|
||||
|
||||
return 0;
|
||||
|
||||
err_register:
|
||||
device_unregister(&gpriv->gadget.dev);
|
||||
err_add_udc:
|
||||
kfree(gpriv->uep);
|
||||
|
||||
|
@ -933,6 +916,8 @@ void usbhs_mod_gadget_remove(struct usbhs_priv *priv)
|
|||
|
||||
usb_del_gadget_udc(&gpriv->gadget);
|
||||
|
||||
device_unregister(&gpriv->gadget.dev);
|
||||
|
||||
usbhsg_controller_unregister(gpriv);
|
||||
|
||||
kfree(gpriv->uep);
|
||||
|
|
Loading…
Reference in a new issue