Merge branch 'docs-next' of git://git.lwn.net/linux-2.6
[linux-2.6/next.git] / include / linux / pm_runtime.h
blob44087044910ff3b13aa72810ad741423de6f1960
1 /*
2 * pm_runtime.h - Device run-time power management helper functions.
4 * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>
6 * This file is released under the GPLv2.
7 */
9 #ifndef _LINUX_PM_RUNTIME_H
10 #define _LINUX_PM_RUNTIME_H
12 #include <linux/device.h>
13 #include <linux/pm.h>
15 #ifdef CONFIG_PM_RUNTIME
17 extern struct workqueue_struct *pm_wq;
19 extern int pm_runtime_idle(struct device *dev);
20 extern int pm_runtime_suspend(struct device *dev);
21 extern int pm_runtime_resume(struct device *dev);
22 extern int pm_request_idle(struct device *dev);
23 extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
24 extern int pm_request_resume(struct device *dev);
25 extern int __pm_runtime_get(struct device *dev, bool sync);
26 extern int __pm_runtime_put(struct device *dev, bool sync);
27 extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
28 extern int pm_runtime_barrier(struct device *dev);
29 extern void pm_runtime_enable(struct device *dev);
30 extern void __pm_runtime_disable(struct device *dev, bool check_resume);
32 static inline bool pm_children_suspended(struct device *dev)
34 return dev->power.ignore_children
35 || !atomic_read(&dev->power.child_count);
38 static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
40 dev->power.ignore_children = enable;
43 static inline void pm_runtime_get_noresume(struct device *dev)
45 atomic_inc(&dev->power.usage_count);
48 static inline void pm_runtime_put_noidle(struct device *dev)
50 atomic_add_unless(&dev->power.usage_count, -1, 0);
53 #else /* !CONFIG_PM_RUNTIME */
55 static inline int pm_runtime_idle(struct device *dev) { return -ENOSYS; }
56 static inline int pm_runtime_suspend(struct device *dev) { return -ENOSYS; }
57 static inline int pm_runtime_resume(struct device *dev) { return 0; }
58 static inline int pm_request_idle(struct device *dev) { return -ENOSYS; }
59 static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
61 return -ENOSYS;
63 static inline int pm_request_resume(struct device *dev) { return 0; }
64 static inline int __pm_runtime_get(struct device *dev, bool sync) { return 1; }
65 static inline int __pm_runtime_put(struct device *dev, bool sync) { return 0; }
66 static inline int __pm_runtime_set_status(struct device *dev,
67 unsigned int status) { return 0; }
68 static inline int pm_runtime_barrier(struct device *dev) { return 0; }
69 static inline void pm_runtime_enable(struct device *dev) {}
70 static inline void __pm_runtime_disable(struct device *dev, bool c) {}
72 static inline bool pm_children_suspended(struct device *dev) { return false; }
73 static inline void pm_suspend_ignore_children(struct device *dev, bool en) {}
74 static inline void pm_runtime_get_noresume(struct device *dev) {}
75 static inline void pm_runtime_put_noidle(struct device *dev) {}
77 #endif /* !CONFIG_PM_RUNTIME */
79 static inline int pm_runtime_get(struct device *dev)
81 return __pm_runtime_get(dev, false);
84 static inline int pm_runtime_get_sync(struct device *dev)
86 return __pm_runtime_get(dev, true);
89 static inline int pm_runtime_put(struct device *dev)
91 return __pm_runtime_put(dev, false);
94 static inline int pm_runtime_put_sync(struct device *dev)
96 return __pm_runtime_put(dev, true);
99 static inline int pm_runtime_set_active(struct device *dev)
101 return __pm_runtime_set_status(dev, RPM_ACTIVE);
104 static inline void pm_runtime_set_suspended(struct device *dev)
106 __pm_runtime_set_status(dev, RPM_SUSPENDED);
109 static inline void pm_runtime_disable(struct device *dev)
111 __pm_runtime_disable(dev, true);
114 #endif