]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/usb/core/hub.c
USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume
[karo-tx-linux.git] / drivers / usb / core / hub.c
index 090469ebfcfff3a1fb686c4adbf0817bc1b27f22..229a73f64304d1395e76e8ec0a277e1eba013da8 100644 (file)
@@ -1691,8 +1691,19 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
         */
        pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
 
-       /* Hubs have proper suspend/resume support. */
-       usb_enable_autosuspend(hdev);
+       /*
+        * Hubs have proper suspend/resume support, except for root hubs
+        * where the controller driver doesn't have bus_suspend and
+        * bus_resume methods.
+        */
+       if (hdev->parent) {             /* normal device */
+               usb_enable_autosuspend(hdev);
+       } else {                        /* root hub */
+               const struct hc_driver *drv = bus_to_hcd(hdev->bus)->driver;
+
+               if (drv->bus_suspend && drv->bus_resume)
+                       usb_enable_autosuspend(hdev);
+       }
 
        if (hdev->level == MAX_TOPO_LEVEL) {
                dev_err(&intf->dev,