Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45f0a85c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

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: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Tested-by: default avatarKevin Hilman <khilman@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarKevin Hilman <khilman@linaro.org>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
parent cd38ca85
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -660,11 +660,6 @@ Subsystems may wish to conserve code space by using the set of generic power
management callbacks provided by the PM core, defined in
driver/base/power/generic_ops.c:

  int pm_generic_runtime_idle(struct device *dev);
    - invoke the ->runtime_idle() callback provided by the driver of this
      device, if defined, and call pm_runtime_suspend() for this device if the
      return value is 0 or the callback is not defined

  int pm_generic_runtime_suspend(struct device *dev);
    - invoke the ->runtime_suspend() callback provided by the driver of this
      device and return its result, or return -EINVAL if not defined
+1 −6
Original line number Diff line number Diff line
@@ -591,11 +591,6 @@ static int _od_runtime_suspend(struct device *dev)
	return ret;
}

static int _od_runtime_idle(struct device *dev)
{
	return pm_generic_runtime_idle(dev);
}

static int _od_runtime_resume(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
@@ -653,7 +648,7 @@ static int _od_resume_noirq(struct device *dev)
struct dev_pm_domain omap_device_pm_domain = {
	.ops = {
		SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume,
				   _od_runtime_idle)
				   NULL)
		USE_PLATFORM_PM_SLEEP_OPS
		.suspend_noirq = _od_suspend_noirq,
		.resume_noirq = _od_resume_noirq,
+0 −1
Original line number Diff line number Diff line
@@ -886,7 +886,6 @@ static struct dev_pm_domain acpi_general_pm_domain = {
#ifdef CONFIG_PM_RUNTIME
		.runtime_suspend = acpi_subsys_runtime_suspend,
		.runtime_resume = acpi_subsys_runtime_resume,
		.runtime_idle = pm_generic_runtime_idle,
#endif
#ifdef CONFIG_PM_SLEEP
		.prepare = acpi_subsys_prepare,
+1 −1
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ static const struct dev_pm_ops amba_pm = {
	SET_RUNTIME_PM_OPS(
		amba_pm_runtime_suspend,
		amba_pm_runtime_resume,
		pm_generic_runtime_idle
		NULL
	)
};

+1 −1
Original line number Diff line number Diff line
@@ -5430,7 +5430,7 @@ static int ata_port_runtime_idle(struct device *dev)
				return -EBUSY;
	}

	return pm_runtime_suspend(dev);
	return 0;
}

static int ata_port_runtime_suspend(struct device *dev)
Loading