PCI: PM: Replace pci_dev_keep_suspended() with two functions
The code in pci_dev_keep_suspended() is relatively hard to follow due to the negative checks in it and in its callers and the function has a possible side-effect (disabling the PME) which doesn't really match its role. For this reason, move the PME disabling from pci_dev_keep_suspended() to a separate function and change the semantics (and name) of the rest of it, so that 'true' is returned when the device needs to be resumed (and not the other way around). Change the callers of pci_dev_keep_suspended() accordingly. While at it, make the code flow in pci_pm_poweroff() reflect the pci_pm_suspend() more closely to avoid arbitrary differences between them. This is a cosmetic change with no intention to alter behavior. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
@@ -679,6 +679,7 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
|
||||
static int pci_pm_prepare(struct device *dev)
|
||||
{
|
||||
struct device_driver *drv = dev->driver;
|
||||
struct pci_dev *pci_dev = to_pci_dev(dev);
|
||||
|
||||
if (drv && drv->pm && drv->pm->prepare) {
|
||||
int error = drv->pm->prepare(dev);
|
||||
@@ -688,7 +689,15 @@ static int pci_pm_prepare(struct device *dev)
|
||||
if (!error && dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_PREPARE))
|
||||
return 0;
|
||||
}
|
||||
return pci_dev_keep_suspended(to_pci_dev(dev));
|
||||
if (pci_dev_need_resume(pci_dev))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* The PME setting needs to be adjusted here in case the direct-complete
|
||||
* optimization is used with respect to this device.
|
||||
*/
|
||||
pci_dev_adjust_pme(pci_dev);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void pci_pm_complete(struct device *dev)
|
||||
@@ -758,9 +767,11 @@ static int pci_pm_suspend(struct device *dev)
|
||||
* better to resume the device from runtime suspend here.
|
||||
*/
|
||||
if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND) ||
|
||||
!pci_dev_keep_suspended(pci_dev)) {
|
||||
pci_dev_need_resume(pci_dev)) {
|
||||
pm_runtime_resume(dev);
|
||||
pci_dev->state_saved = false;
|
||||
} else {
|
||||
pci_dev_adjust_pme(pci_dev);
|
||||
}
|
||||
|
||||
if (pm->suspend) {
|
||||
@@ -1108,10 +1119,13 @@ static int pci_pm_poweroff(struct device *dev)
|
||||
|
||||
/* The reason to do that is the same as in pci_pm_suspend(). */
|
||||
if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND) ||
|
||||
!pci_dev_keep_suspended(pci_dev))
|
||||
pci_dev_need_resume(pci_dev)) {
|
||||
pm_runtime_resume(dev);
|
||||
pci_dev->state_saved = false;
|
||||
} else {
|
||||
pci_dev_adjust_pme(pci_dev);
|
||||
}
|
||||
|
||||
pci_dev->state_saved = false;
|
||||
if (pm->poweroff) {
|
||||
int error;
|
||||
|
||||
|
Reference in New Issue
Block a user