usb: xhci: Fix suspend/resume when used with OTG core
[cascardo/linux.git] / drivers / usb / host / xhci.c
index 8a7e319..e5568ba 100644 (file)
@@ -891,6 +891,9 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
        struct usb_hcd          *hcd = xhci_to_hcd(xhci);
        u32                     command;
 
+       if (!hcd->state)
+               return 0;
+
        if (hcd->state != HC_STATE_SUSPENDED ||
                        xhci->shared_hcd->state != HC_STATE_SUSPENDED)
                return -EINVAL;
@@ -977,6 +980,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
        int                     retval = 0;
        bool                    comp_timer_running = false;
 
+       if (!hcd->state)
+               return 0;
+
        /* Wait a bit if either of the roothubs need to settle from the
         * transition into bus suspend.
         */