OSDN Git Service

usb: xhci: Fix suspend/resume when used with OTG core
authorRoger Quadros <rogerq@ti.com>
Fri, 29 May 2015 14:01:50 +0000 (17:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 06:45:31 +0000 (15:45 +0900)
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>
drivers/usb/host/xhci-plat.c
drivers/usb/host/xhci.c

index 267787a..890ad9d 100644 (file)
@@ -140,6 +140,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 
        xhci = hcd_to_xhci(hcd);
        xhci->clk = clk;
+       xhci->main_hcd = hcd;
        xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
                        dev_name(&pdev->dev), hcd);
        if (!xhci->shared_hcd) {
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.
         */