Revert "USB: OHCI: Properly handle ohci-exynos suspend"
[firefly-linux-kernel-4.4.55.git] / drivers / usb / host / ohci-exynos.c
index 122e52e88a401e0e20f524871689a4d3da7e5238..17f46fbf047d18c555f708ebf572074ed0c23373 100644 (file)
@@ -204,15 +204,24 @@ static int exynos_ohci_suspend(struct device *dev)
        struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
        struct ohci_hcd *ohci = hcd_to_ohci(hcd);
        struct platform_device *pdev = to_platform_device(dev);
-       bool do_wakeup = device_may_wakeup(dev);
        unsigned long flags;
        int rc = 0;
 
-       rc = ohci_suspend(hcd, do_wakeup);
-       if (rc)
-               return rc;
-
+       /*
+        * Root hub was already suspended. Disable irq emission and
+        * mark HW unaccessible, bail out if RH has been resumed. Use
+        * the spinlock to properly synchronize with possible pending
+        * RH suspend or resume activity.
+        */
        spin_lock_irqsave(&ohci->lock, flags);
+       if (ohci->rh_state != OHCI_RH_SUSPENDED &&
+                       ohci->rh_state != OHCI_RH_HALTED) {
+               rc = -EINVAL;
+               goto fail;
+       }
+
+       clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+
        if (exynos_ohci->otg)
                exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
 
@@ -220,6 +229,7 @@ static int exynos_ohci_suspend(struct device *dev)
 
        clk_disable_unprepare(exynos_ohci->clk);
 
+fail:
        spin_unlock_irqrestore(&ohci->lock, flags);
 
        return rc;