Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / usb / core / hcd.c
index 278be05..11cee55 100644 (file)
@@ -2646,7 +2646,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)) {
@@ -2666,6 +2666,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
                                goto err_phy;
                        }
                        hcd->phy = phy;
+                       hcd->remove_phy = 1;
                }
        }
 
@@ -2812,7 +2813,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);
@@ -2896,7 +2897,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);