Commit fbadc58dd3a52c330c8f3926aa93011bf9d91fa0
Committed by
Rafael J. Wysocki
1 parent
43720bd601
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
PM / Runtime: Add new helper function: pm_runtime_active()
This boolean function simply returns whether or not the runtime status of the device is 'active'. The typical scenario is driver calls pm_runtime_get firstly, then check pm_runtime_active in atomic environment. Also add entry to Documentation/power/runtime.txt Signed-off-by: Yanmin Zhang <yanmin.zhang@intel.com> Signed-off-by: ShuoX Liu <shuox.liu@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Showing 2 changed files with 11 additions and 0 deletions Side-by-side Diff
Documentation/power/runtime_pm.txt
... | ... | @@ -426,6 +426,10 @@ |
426 | 426 | 'power.runtime_error' is set or 'power.disable_depth' is greater than |
427 | 427 | zero) |
428 | 428 | |
429 | + bool pm_runtime_active(struct device *dev); | |
430 | + - return true if the device's runtime PM status is 'active' or its | |
431 | + 'power.disable_depth' field is not equal to zero, or false otherwise | |
432 | + | |
429 | 433 | bool pm_runtime_suspended(struct device *dev); |
430 | 434 | - return true if the device's runtime PM status is 'suspended' and its |
431 | 435 | 'power.disable_depth' field is equal to zero, or false otherwise |
include/linux/pm_runtime.h
... | ... | @@ -80,6 +80,12 @@ |
80 | 80 | && !dev->power.disable_depth; |
81 | 81 | } |
82 | 82 | |
83 | +static inline bool pm_runtime_active(struct device *dev) | |
84 | +{ | |
85 | + return dev->power.runtime_status == RPM_ACTIVE | |
86 | + || dev->power.disable_depth; | |
87 | +} | |
88 | + | |
83 | 89 | static inline bool pm_runtime_status_suspended(struct device *dev) |
84 | 90 | { |
85 | 91 | return dev->power.runtime_status == RPM_SUSPENDED; |
... | ... | @@ -132,6 +138,7 @@ |
132 | 138 | static inline bool device_run_wake(struct device *dev) { return false; } |
133 | 139 | static inline void device_set_run_wake(struct device *dev, bool enable) {} |
134 | 140 | static inline bool pm_runtime_suspended(struct device *dev) { return false; } |
141 | +static inline bool pm_runtime_active(struct device *dev) { return true; } | |
135 | 142 | static inline bool pm_runtime_status_suspended(struct device *dev) { return false; } |
136 | 143 | static inline bool pm_runtime_enabled(struct device *dev) { return false; } |
137 | 144 |