summaryrefslogtreecommitdiff
path: root/drivers/base/power/runtime.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2025-02-18 21:13:09 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2025-02-18 21:43:06 +0100
commit758cc55ce3d5d79e8f98adbd03ad2cd29133af33 (patch)
tree605ad2bf4ed4992c1cbd5f8d4112f2c2d06cd651 /drivers/base/power/runtime.c
parent3e5eee147b7b0f5a93f56beffe34e81fdd00fa0d (diff)
PM: runtime: Introduce pm_runtime_blocked()
Introduce a new helper function called pm_runtime_blocked() for checking the power.last_status value indicating whether or not enabling runtime PM for the given device has been blocked (which happens in the "prepare" phase of system-wide suspend if runtime PM is disabled for the given device at that point). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://patch.msgid.link/4632087.LvFx2qVVIh@rjwysocki.net
Diffstat (limited to 'drivers/base/power/runtime.c')
-rw-r--r--drivers/base/power/runtime.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 797ea38ceba7..c0f5a9f89299 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1555,6 +1555,23 @@ out:
}
EXPORT_SYMBOL_GPL(pm_runtime_enable);
+bool pm_runtime_blocked(struct device *dev)
+{
+ bool ret;
+
+ /*
+ * dev->power.last_status is a bit field, so in case it is updated via
+ * RMW, read it under the spin lock.
+ */
+ spin_lock_irq(&dev->power.lock);
+
+ ret = dev->power.last_status == RPM_BLOCKED;
+
+ spin_unlock_irq(&dev->power.lock);
+
+ return ret;
+}
+
static void pm_runtime_disable_action(void *data)
{
pm_runtime_dont_use_autosuspend(data);