diff options
-rw-r--r-- | drivers/usb/gadget/dummy_hcd.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index fdab97a27c08..4d2946e540cf 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -816,15 +816,14 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
816 | dum->gadget.dev.driver = &driver->driver; | 816 | dum->gadget.dev.driver = &driver->driver; |
817 | dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", | 817 | dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", |
818 | driver->driver.name); | 818 | driver->driver.name); |
819 | if ((retval = driver->bind (&dum->gadget)) != 0) { | 819 | if ((retval = driver->bind (&dum->gadget)) != 0) |
820 | dum->driver = NULL; | 820 | goto err_bind_gadget; |
821 | dum->gadget.dev.driver = NULL; | ||
822 | return retval; | ||
823 | } | ||
824 | 821 | ||
825 | driver->driver.bus = dum->gadget.dev.parent->bus; | 822 | driver->driver.bus = dum->gadget.dev.parent->bus; |
826 | driver_register (&driver->driver); | 823 | if ((retval = driver_register (&driver->driver)) != 0) |
827 | device_bind_driver (&dum->gadget.dev); | 824 | goto err_register; |
825 | if ((retval = device_bind_driver (&dum->gadget.dev)) != 0) | ||
826 | goto err_bind_driver; | ||
828 | 827 | ||
829 | /* khubd will enumerate this in a while */ | 828 | /* khubd will enumerate this in a while */ |
830 | spin_lock_irq (&dum->lock); | 829 | spin_lock_irq (&dum->lock); |
@@ -834,6 +833,19 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
834 | 833 | ||
835 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 834 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
836 | return 0; | 835 | return 0; |
836 | |||
837 | err_bind_driver: | ||
838 | driver_unregister (&driver->driver); | ||
839 | err_register: | ||
840 | driver->unbind (&dum->gadget); | ||
841 | spin_lock_irq (&dum->lock); | ||
842 | dum->pullup = 0; | ||
843 | set_link_state (dum); | ||
844 | spin_unlock_irq (&dum->lock); | ||
845 | err_bind_gadget: | ||
846 | dum->driver = NULL; | ||
847 | dum->gadget.dev.driver = NULL; | ||
848 | return retval; | ||
837 | } | 849 | } |
838 | EXPORT_SYMBOL (usb_gadget_register_driver); | 850 | EXPORT_SYMBOL (usb_gadget_register_driver); |
839 | 851 | ||
@@ -916,7 +928,9 @@ static int dummy_udc_probe (struct platform_device *pdev) | |||
916 | usb_get_hcd (dummy_to_hcd (dum)); | 928 | usb_get_hcd (dummy_to_hcd (dum)); |
917 | 929 | ||
918 | platform_set_drvdata (pdev, dum); | 930 | platform_set_drvdata (pdev, dum); |
919 | device_create_file (&dum->gadget.dev, &dev_attr_function); | 931 | rc = device_create_file (&dum->gadget.dev, &dev_attr_function); |
932 | if (rc < 0) | ||
933 | device_unregister (&dum->gadget.dev); | ||
920 | return rc; | 934 | return rc; |
921 | } | 935 | } |
922 | 936 | ||
@@ -1864,8 +1878,7 @@ static int dummy_start (struct usb_hcd *hcd) | |||
1864 | #endif | 1878 | #endif |
1865 | 1879 | ||
1866 | /* FIXME 'urbs' should be a per-device thing, maybe in usbcore */ | 1880 | /* FIXME 'urbs' should be a per-device thing, maybe in usbcore */ |
1867 | device_create_file (dummy_dev(dum), &dev_attr_urbs); | 1881 | return device_create_file (dummy_dev(dum), &dev_attr_urbs); |
1868 | return 0; | ||
1869 | } | 1882 | } |
1870 | 1883 | ||
1871 | static void dummy_stop (struct usb_hcd *hcd) | 1884 | static void dummy_stop (struct usb_hcd *hcd) |