From f78c4cffb86a9f1732674d810ac338cd694b1885 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Tue, 10 Dec 2013 14:37:42 +0100 Subject: PM / Sleep: Add macro to define common late/early system PM callbacks We use the same approach as for the existing SET_SYSTEM_SLEEP_PM_OPS, but for the late and early callbacks instead. The new SET_LATE_SYSTEM_SLEEP_PM_OPS, defined for CONFIG_PM_SLEEP, will point ->suspend_late, ->freeze_late and ->poweroff_late to the same function. Vice verse happens for ->resume_early, ->thaw_early and ->restore_early. Cc: Kevin Hilman Cc: Alan Stern Signed-off-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki --- include/linux/pm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/linux/pm.h') diff --git a/include/linux/pm.h b/include/linux/pm.h index a224c7f..970b705 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -311,6 +311,18 @@ struct dev_pm_ops { #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) #endif +#ifdef CONFIG_PM_SLEEP +#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ + .suspend_late = suspend_fn, \ + .resume_early = resume_fn, \ + .freeze_late = suspend_fn, \ + .thaw_early = resume_fn, \ + .poweroff_late = suspend_fn, \ + .restore_early = resume_fn, +#else +#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) +#endif + #ifdef CONFIG_PM_RUNTIME #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ .runtime_suspend = suspend_fn, \ -- cgit v1.1 From d9fb563d3cdfd774ee0a7c03e98bb305cdd613eb Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Tue, 10 Dec 2013 14:37:40 +0100 Subject: PM / Runtime: Add second macro for definition of runtime PM callbacks By having the runtime PM callbacks implemented for CONFIG_PM, these becomes available in all combinations of CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. The benefit using this, is that we don't need to implement the wrapper functions which handles runtime PM resourses, typically called from both runtime PM and system PM callbacks. Instead the runtime PM callbacks can be invoked directly from system PM callbacks, which is useful for some drivers, subsystems and power domains. Use the new macro SET_PM_RUNTIME_PM_OPS in cases were the above makes sense. Make sure the callbacks are encapsulated within CONFIG_PM instead of CONFIG_PM_RUNTIME. Do note that the old macro SET_RUNTIME_PM_OPS, which is being quite widely used right now, requires the callbacks to be defined for CONFIG_PM_RUNTIME. In many cases it will certainly be convenient to convert to the new macro above, but that will have to be distinguished in case by case. Cc: Kevin Hilman Cc: Alan Stern Signed-off-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki --- include/linux/pm.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/linux/pm.h') diff --git a/include/linux/pm.h b/include/linux/pm.h index a224c7f..7a830a7 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -320,6 +320,15 @@ struct dev_pm_ops { #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) #endif +#ifdef CONFIG_PM +#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = suspend_fn, \ + .runtime_resume = resume_fn, \ + .runtime_idle = idle_fn, +#else +#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) +#endif + /* * Use this if you want to use the same suspend and resume callbacks for suspend * to RAM and hibernation. -- cgit v1.1