Skip to content

Commit 9d86191

Browse files
pcercueirafaeljw
authored andcommitted
PM: runtime: Add DEFINE_RUNTIME_DEV_PM_OPS() macro
A lot of drivers create a dev_pm_ops struct with the system sleep suspend/resume callbacks set to pm_runtime_force_suspend() and pm_runtime_force_resume(). These drivers can now use the DEFINE_RUNTIME_DEV_PM_OPS() macro, which will use pm_runtime_force_{suspend,resume}() as the system sleep callbacks, while having the same dead code removal characteristic that is already provided by DEFINE_SIMPLE_DEV_PM_OPS(). Signed-off-by: Paul Cercueil <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Reviewed-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 0ae101f commit 9d86191

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/linux/pm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ const struct dev_pm_ops __maybe_unused name = { \
414414
* .resume_early(), to the same routines as .runtime_suspend() and
415415
* .runtime_resume(), respectively (and analogously for hibernation).
416416
*
417-
* Deprecated. You most likely don't want this macro.
417+
* Deprecated. You most likely don't want this macro. Use
418+
* DEFINE_RUNTIME_DEV_PM_OPS() instead.
418419
*/
419420
#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
420421
const struct dev_pm_ops __maybe_unused name = { \

include/linux/pm_runtime.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222
usage_count */
2323
#define RPM_AUTO 0x08 /* Use autosuspend_delay */
2424

25+
/*
26+
* Use this for defining a set of PM operations to be used in all situations
27+
* (system suspend, hibernation or runtime PM).
28+
*
29+
* Note that the behaviour differs from the deprecated UNIVERSAL_DEV_PM_OPS()
30+
* macro, which uses the provided callbacks for both runtime PM and system
31+
* sleep, while DEFINE_RUNTIME_DEV_PM_OPS() uses pm_runtime_force_suspend()
32+
* and pm_runtime_force_resume() for its system sleep callbacks.
33+
*/
34+
#define DEFINE_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
35+
_DEFINE_DEV_PM_OPS(name, pm_runtime_force_suspend, \
36+
pm_runtime_force_resume, suspend_fn, \
37+
resume_fn, idle_fn)
38+
2539
#ifdef CONFIG_PM
2640
extern struct workqueue_struct *pm_wq;
2741

0 commit comments

Comments
 (0)