summaryrefslogtreecommitdiff
path: root/drivers/usb/host/xhci.c
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2015-05-29 17:01:50 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-31 15:45:31 +0900
commit9fa733f24bb54dd532b5f5d7abc275c4a547c69f (patch)
treec8a21e12577e19b7c1941af0b5de9c493c9616a6 /drivers/usb/host/xhci.c
parentad6b1d914a9e07f3b9a9ae3396f3c840d0070539 (diff)
usb: xhci: Fix suspend/resume when used with OTG core
In the OTG case, the controller might not yet have been added or is removed before the system suspends. Assign xhci->main_hcd during probe to prevent NULL pointer de-reference in xhci_suspend/resume(). Use the hcd->state flag to check if HCD is halted and if that is so do nothing for xhci_suspend/resume(). [Only for xhci-plat devices, pci devices need it in gen_setup -Mathias] Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/xhci.c')
-rw-r--r--drivers/usb/host/xhci.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8a7e31927a3b..e5568bab5e70 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -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.
*/