aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pm.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-03-06 15:28:37 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2010-03-06 15:28:37 -0500
commitd690b2cd222afc75320b9b8e9da7df02e9e630ca (patch)
tree41b7f13c7176bc74d7836a7ec585a5a456302ea9 /include/linux/pm.h
parent87d1b3e60b55ef65f10054ccc319e5d67cf010e9 (diff)
PM: Provide generic subsystem-level callbacks
There are subsystems whose power management callbacks only need to invoke the callbacks provided by device drivers. Still, their system sleep PM callbacks should play well with the runtime PM callbacks, so that devices suspended at run time can be left in that state for a system sleep transition. Provide a set of generic PM callbacks for such subsystems and define convenience macros for populating dev_pm_ops structures. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'include/linux/pm.h')
-rw-r--r--include/linux/pm.h51
1 files changed, 45 insertions, 6 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h
index e80df06ad22a..8e258c727971 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -215,20 +215,59 @@ struct dev_pm_ops {
215 int (*runtime_idle)(struct device *dev); 215 int (*runtime_idle)(struct device *dev);
216}; 216};
217 217
218#ifdef CONFIG_PM_SLEEP
219#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
220 .suspend = suspend_fn, \
221 .resume = resume_fn, \
222 .freeze = suspend_fn, \
223 .thaw = resume_fn, \
224 .poweroff = suspend_fn, \
225 .restore = resume_fn,
226#else
227#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
228#endif
229
230#ifdef CONFIG_PM_RUNTIME
231#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
232 .runtime_suspend = suspend_fn, \
233 .runtime_resume = resume_fn, \
234 .runtime_idle = idle_fn,
235#else
236#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
237#endif
238
218/* 239/*
219 * Use this if you want to use the same suspend and resume callbacks for suspend 240 * Use this if you want to use the same suspend and resume callbacks for suspend
220 * to RAM and hibernation. 241 * to RAM and hibernation.
221 */ 242 */
222#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ 243#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
223const struct dev_pm_ops name = { \ 244const struct dev_pm_ops name = { \
224 .suspend = suspend_fn, \ 245 SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
225 .resume = resume_fn, \ 246}
226 .freeze = suspend_fn, \ 247
227 .thaw = resume_fn, \ 248/*
228 .poweroff = suspend_fn, \ 249 * Use this for defining a set of PM operations to be used in all situations
229 .restore = resume_fn, \ 250 * (sustem suspend, hibernation or runtime PM).
251 */
252#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
253const struct dev_pm_ops name = { \
254 SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
255 SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
230} 256}
231 257
258/*
259 * Use this for subsystems (bus types, device types, device classes) that don't
260 * need any special suspend/resume handling in addition to invoking the PM
261 * callbacks provided by device drivers supporting both the system sleep PM and
262 * runtime PM, make the pm member point to generic_subsys_pm_ops.
263 */
264#ifdef CONFIG_PM_OPS
265extern struct dev_pm_ops generic_subsys_pm_ops;
266#define GENERIC_SUBSYS_PM_OPS (&generic_subsys_pm_ops)
267#else
268#define GENERIC_SUBSYS_PM_OPS NULL
269#endif
270
232/** 271/**
233 * PM_EVENT_ messages 272 * PM_EVENT_ messages
234 * 273 *