Merge tag 'v4.4-rc5'
[firefly-linux-kernel-4.4.55.git] / drivers / usb / core / hcd-pci.c
index 4676917e2b1f63fa19bc8d31fc7b20bfdaef6f06..9eb1cff28bd4b2499e4dfd9ed8b91e53901df184 100644 (file)
@@ -171,6 +171,8 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
  * through the hotplug entry's driver_data.
  *
  * Store this function in the HCD's struct pci_driver as probe().
+ *
+ * Return: 0 if successful.
  */
 int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
@@ -190,7 +192,6 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
        if (pci_enable_device(dev) < 0)
                return -ENODEV;
-       dev->current_state = PCI_D0;
 
        /*
         * The xHCI driver has its own irq management
@@ -213,6 +214,9 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
                goto disable_pci;
        }
 
+       hcd->amd_resume_bug = (usb_hcd_amd_remote_wakeup_quirk(dev) &&
+                       driver->flags & (HCD_USB11 | HCD_USB3)) ? 1 : 0;
+
        if (driver->flags & HCD_MEMORY) {
                /* EHCI, OHCI */
                hcd->rsrc_start = pci_resource_start(dev, 0);
@@ -277,6 +281,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
        if (retval != 0)
                goto unmap_registers;
+       device_wakeup_enable(hcd->self.controller);
 
        if (pci_dev_run_wake(dev))
                pm_runtime_put_noidle(&dev->dev);
@@ -375,6 +380,8 @@ void usb_hcd_pci_shutdown(struct pci_dev *dev)
        if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) &&
                        hcd->driver->shutdown) {
                hcd->driver->shutdown(hcd);
+               if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0)
+                       free_irq(hcd->irq, hcd);
                pci_disable_device(dev);
        }
 }
@@ -422,7 +429,6 @@ static int check_root_hub_suspended(struct device *dev)
        return 0;
 }
 
-#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME)
 static int suspend_common(struct device *dev, bool do_wakeup)
 {
        struct pci_dev          *pci_dev = to_pci_dev(dev);
@@ -521,7 +527,6 @@ static int resume_common(struct device *dev, int event)
        }
        return retval;
 }
-#endif /* SLEEP || RUNTIME */
 
 #ifdef CONFIG_PM_SLEEP
 
@@ -600,8 +605,6 @@ static int hcd_pci_restore(struct device *dev)
 
 #endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_PM_RUNTIME
-
 static int hcd_pci_runtime_suspend(struct device *dev)
 {
        int     retval;
@@ -623,13 +626,6 @@ static int hcd_pci_runtime_resume(struct device *dev)
        return retval;
 }
 
-#else
-
-#define hcd_pci_runtime_suspend        NULL
-#define hcd_pci_runtime_resume NULL
-
-#endif /* CONFIG_PM_RUNTIME */
-
 const struct dev_pm_ops usb_hcd_pci_pm_ops = {
        .suspend        = hcd_pci_suspend,
        .suspend_noirq  = hcd_pci_suspend_noirq,