PCI/PM: Unfold pci_platform_power_transition() in pci_power_up()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 5 May 2022 18:05:15 +0000 (20:05 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 5 May 2022 19:19:48 +0000 (14:19 -0500)
Some actions carried out by pci_platform_power_transition(() in
pci_power_up() are redundant, but before dealing with them, make
pci_power_up() call the pci_platform_power_transition() code directly
(and avoid a redundant check when pm_cap is unset while at it).

Link: https://lore.kernel.org/r/1922486.PYKUYFuaPT@kreacher
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c

index 056e8284b5fd54934f95ba669342c1736f0eb37d..bc4af86da3f9f34f2098d0db5118b2598146701a 100644 (file)
@@ -1194,8 +1194,15 @@ int pci_power_up(struct pci_dev *dev)
 {
        bool need_restore = false;
        u16 pmcsr;
+       int ret;
 
-       pci_platform_power_transition(dev, PCI_D0);
+       ret = platform_pci_set_power_state(dev, PCI_D0);
+       if (!ret) {
+               pci_update_current_state(dev, PCI_D0);
+       } else if (!dev->pm_cap) { /* Fall back to PCI_D0 */
+               dev->current_state = PCI_D0;
+               return 0;
+       }
 
        if (dev->current_state == PCI_D0)
                return 0;