diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-03 15:49:52 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-03 15:49:52 -0400 |
commit | 45f0a85c8258741d11bda25c0a5669c06267204a (patch) | |
tree | a618cce0583426a5c7f53f56cf19139a6f9733ce /drivers/pci/pci-driver.c | |
parent | cd38ca854de15b26eb91009137cbe157d8a8e773 (diff) |
PM / Runtime: Rework the "runtime idle" helper routine
The "runtime idle" helper routine, rpm_idle(), currently ignores
return values from .runtime_idle() callbacks executed by it.
However, it turns out that many subsystems use
pm_generic_runtime_idle() which checks the return value of the
driver's callback and executes pm_runtime_suspend() for the device
unless that value is not 0. If that logic is moved to rpm_idle()
instead, pm_generic_runtime_idle() can be dropped and its users
will not need any .runtime_idle() callbacks any more.
Moreover, the PCI, SCSI, and SATA subsystems' .runtime_idle()
routines, pci_pm_runtime_idle(), scsi_runtime_idle(), and
ata_port_runtime_idle(), respectively, as well as a few drivers'
ones may be simplified if rpm_idle() calls rpm_suspend() after 0 has
been returned by the .runtime_idle() callback executed by it.
To reduce overall code bloat, make the changes described above.
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Tested-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Kevin Hilman <khilman@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r-- | drivers/pci/pci-driver.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 79277fb36c6b..e6515e21afa3 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -1050,26 +1050,22 @@ static int pci_pm_runtime_idle(struct device *dev) | |||
1050 | { | 1050 | { |
1051 | struct pci_dev *pci_dev = to_pci_dev(dev); | 1051 | struct pci_dev *pci_dev = to_pci_dev(dev); |
1052 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 1052 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
1053 | int ret = 0; | ||
1053 | 1054 | ||
1054 | /* | 1055 | /* |
1055 | * If pci_dev->driver is not set (unbound), the device should | 1056 | * If pci_dev->driver is not set (unbound), the device should |
1056 | * always remain in D0 regardless of the runtime PM status | 1057 | * always remain in D0 regardless of the runtime PM status |
1057 | */ | 1058 | */ |
1058 | if (!pci_dev->driver) | 1059 | if (!pci_dev->driver) |
1059 | goto out; | 1060 | return 0; |
1060 | 1061 | ||
1061 | if (!pm) | 1062 | if (!pm) |
1062 | return -ENOSYS; | 1063 | return -ENOSYS; |
1063 | 1064 | ||
1064 | if (pm->runtime_idle) { | 1065 | if (pm->runtime_idle) |
1065 | int ret = pm->runtime_idle(dev); | 1066 | ret = pm->runtime_idle(dev); |
1066 | if (ret) | ||
1067 | return ret; | ||
1068 | } | ||
1069 | 1067 | ||
1070 | out: | 1068 | return ret; |
1071 | pm_runtime_suspend(dev); | ||
1072 | return 0; | ||
1073 | } | 1069 | } |
1074 | 1070 | ||
1075 | #else /* !CONFIG_PM_RUNTIME */ | 1071 | #else /* !CONFIG_PM_RUNTIME */ |