diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2022-04-14 15:07:24 +0200 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2022-05-05 14:19:48 -0500 |
commit | 9c384ddd6eb2ee90d19cd01128748dec85fa36e3 (patch) | |
tree | 73a3a844595db376957cc136c8cb8e5ff3b1e494 /drivers/pci/pci.c | |
parent | 8221ecd4e4620cf2f0e942cafcdecac1685f8f16 (diff) | |
download | linux-9c384ddd6eb2ee90d19cd01128748dec85fa36e3.tar.bz2 |
PCI/PM: Rearrange pci_update_current_state()
Save one config space access in pci_update_current_state() by testing the
retrieved PCI_PM_CTRL register value against PCI_POSSIBLE_ERROR() instead
of invoking pci_device_is_present() separately.
While at it, drop a pair of unnecessary parens.
No expected functional impact.
Link: https://lore.kernel.org/r/1917095.PYKUYFuaPT@kreacher
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 992417646128..11f95ca84b22 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1201,14 +1201,17 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) */ void pci_update_current_state(struct pci_dev *dev, pci_power_t state) { - if (platform_pci_get_power_state(dev) == PCI_D3cold || - !pci_device_is_present(dev)) { + if (platform_pci_get_power_state(dev) == PCI_D3cold) { dev->current_state = PCI_D3cold; } else if (dev->pm_cap) { u16 pmcsr; pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); - dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); + if (PCI_POSSIBLE_ERROR(pmcsr)) { + dev->current_state = PCI_D3cold; + return; + } + dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK; } else { dev->current_state = state; } |