Merge tag 'usb-for-v3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
[deliverable/linux.git] / drivers / usb / core / hcd.c
index b84fb141e122f7f0d60d9e4ba09642c7c9e15492..2f2118fa36a8d2bfa4704d22ff1b895ec080b258 100644 (file)
@@ -2060,6 +2060,8 @@ int usb_alloc_streams(struct usb_interface *interface,
                return -EINVAL;
        if (dev->speed != USB_SPEED_SUPER)
                return -EINVAL;
+       if (dev->state < USB_STATE_CONFIGURED)
+               return -ENODEV;
 
        for (i = 0; i < num_eps; i++) {
                /* Streams only apply to bulk endpoints. */
@@ -2648,7 +2650,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
                }
        }
 
-       if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
+       if (IS_ENABLED(CONFIG_GENERIC_PHY) && !hcd->phy) {
                struct phy *phy = phy_get(hcd->self.controller, "usb");
 
                if (IS_ERR(phy)) {
@@ -2668,6 +2670,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
                                goto err_phy;
                        }
                        hcd->phy = phy;
+                       hcd->remove_phy = 1;
                }
        }
 
@@ -2814,7 +2817,7 @@ err_allocate_root_hub:
 err_register_bus:
        hcd_buffer_destroy(hcd);
 err_create_buf:
-       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
+       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
                phy_power_off(hcd->phy);
                phy_exit(hcd->phy);
                phy_put(hcd->phy);
@@ -2898,7 +2901,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
        usb_deregister_bus(&hcd->self);
        hcd_buffer_destroy(hcd);
 
-       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
+       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
                phy_power_off(hcd->phy);
                phy_exit(hcd->phy);
                phy_put(hcd->phy);
This page took 0.032032 seconds and 5 git commands to generate.