diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-11-17 21:19:06 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-29 09:19:03 -0500 |
commit | f8eff0a06116aee127152674e9ea9c51aecf6b69 (patch) | |
tree | 5281cea33447a188e185edacba72979132ab4211 /drivers | |
parent | 5d193ce8f1fa7c67c7fd7be2c03ef31eed344a4f (diff) |
usb: renesas_usbhs: fixup device_register timing
current renesas_usbhs is using new style udc_start/stop from
af1d7056a5c1e5eaaf807ddd1423101db84668d0
(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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/renesas_usbhs/mod_gadget.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index d9717e0bc1ff..ef82274ce70b 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -751,53 +751,31 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget, | |||
751 | struct usb_gadget_driver *driver) | 751 | struct usb_gadget_driver *driver) |
752 | { | 752 | { |
753 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | 753 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); |
754 | struct usbhs_priv *priv; | 754 | struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); |
755 | struct device *dev; | ||
756 | int ret; | ||
757 | 755 | ||
758 | if (!driver || | 756 | if (!driver || |
759 | !driver->setup || | 757 | !driver->setup || |
760 | driver->speed != USB_SPEED_HIGH) | 758 | driver->speed != USB_SPEED_HIGH) |
761 | return -EINVAL; | 759 | return -EINVAL; |
762 | 760 | ||
763 | dev = usbhsg_gpriv_to_dev(gpriv); | ||
764 | priv = usbhsg_gpriv_to_priv(gpriv); | ||
765 | |||
766 | /* first hook up the driver ... */ | 761 | /* first hook up the driver ... */ |
767 | gpriv->driver = driver; | 762 | gpriv->driver = driver; |
768 | gpriv->gadget.dev.driver = &driver->driver; | 763 | gpriv->gadget.dev.driver = &driver->driver; |
769 | 764 | ||
770 | ret = device_add(&gpriv->gadget.dev); | ||
771 | if (ret) { | ||
772 | dev_err(dev, "device_add error %d\n", ret); | ||
773 | goto add_fail; | ||
774 | } | ||
775 | |||
776 | return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD); | 765 | return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD); |
777 | |||
778 | add_fail: | ||
779 | gpriv->driver = NULL; | ||
780 | gpriv->gadget.dev.driver = NULL; | ||
781 | |||
782 | return ret; | ||
783 | } | 766 | } |
784 | 767 | ||
785 | static int usbhsg_gadget_stop(struct usb_gadget *gadget, | 768 | static int usbhsg_gadget_stop(struct usb_gadget *gadget, |
786 | struct usb_gadget_driver *driver) | 769 | struct usb_gadget_driver *driver) |
787 | { | 770 | { |
788 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | 771 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); |
789 | struct usbhs_priv *priv; | 772 | struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); |
790 | struct device *dev; | ||
791 | 773 | ||
792 | if (!driver || | 774 | if (!driver || |
793 | !driver->unbind) | 775 | !driver->unbind) |
794 | return -EINVAL; | 776 | return -EINVAL; |
795 | 777 | ||
796 | dev = usbhsg_gpriv_to_dev(gpriv); | ||
797 | priv = usbhsg_gpriv_to_priv(gpriv); | ||
798 | |||
799 | usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD); | 778 | usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD); |
800 | device_del(&gpriv->gadget.dev); | ||
801 | gpriv->driver = NULL; | 779 | gpriv->driver = NULL; |
802 | 780 | ||
803 | return 0; | 781 | return 0; |
@@ -876,12 +854,14 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
876 | /* | 854 | /* |
877 | * init gadget | 855 | * init gadget |
878 | */ | 856 | */ |
879 | device_initialize(&gpriv->gadget.dev); | ||
880 | dev_set_name(&gpriv->gadget.dev, "gadget"); | 857 | dev_set_name(&gpriv->gadget.dev, "gadget"); |
881 | gpriv->gadget.dev.parent = dev; | 858 | gpriv->gadget.dev.parent = dev; |
882 | gpriv->gadget.name = "renesas_usbhs_udc"; | 859 | gpriv->gadget.name = "renesas_usbhs_udc"; |
883 | gpriv->gadget.ops = &usbhsg_gadget_ops; | 860 | gpriv->gadget.ops = &usbhsg_gadget_ops; |
884 | gpriv->gadget.is_dualspeed = 1; | 861 | gpriv->gadget.is_dualspeed = 1; |
862 | ret = device_register(&gpriv->gadget.dev); | ||
863 | if (ret < 0) | ||
864 | goto err_add_udc; | ||
885 | 865 | ||
886 | INIT_LIST_HEAD(&gpriv->gadget.ep_list); | 866 | INIT_LIST_HEAD(&gpriv->gadget.ep_list); |
887 | 867 | ||
@@ -912,12 +892,15 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
912 | 892 | ||
913 | ret = usb_add_gadget_udc(dev, &gpriv->gadget); | 893 | ret = usb_add_gadget_udc(dev, &gpriv->gadget); |
914 | if (ret) | 894 | if (ret) |
915 | goto err_add_udc; | 895 | goto err_register; |
916 | 896 | ||
917 | 897 | ||
918 | dev_info(dev, "gadget probed\n"); | 898 | dev_info(dev, "gadget probed\n"); |
919 | 899 | ||
920 | return 0; | 900 | return 0; |
901 | |||
902 | err_register: | ||
903 | device_unregister(&gpriv->gadget.dev); | ||
921 | err_add_udc: | 904 | err_add_udc: |
922 | kfree(gpriv->uep); | 905 | kfree(gpriv->uep); |
923 | 906 | ||
@@ -933,6 +916,8 @@ void usbhs_mod_gadget_remove(struct usbhs_priv *priv) | |||
933 | 916 | ||
934 | usb_del_gadget_udc(&gpriv->gadget); | 917 | usb_del_gadget_udc(&gpriv->gadget); |
935 | 918 | ||
919 | device_unregister(&gpriv->gadget.dev); | ||
920 | |||
936 | usbhsg_controller_unregister(gpriv); | 921 | usbhsg_controller_unregister(gpriv); |
937 | 922 | ||
938 | kfree(gpriv->uep); | 923 | kfree(gpriv->uep); |