Root/
1 | /* |
2 | * pm_runtime.h - Device run-time power management helper functions. |
3 | * |
4 | * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl> |
5 | * |
6 | * This file is released under the GPLv2. |
7 | */ |
8 | |
9 | #ifndef _LINUX_PM_RUNTIME_H |
10 | #define _LINUX_PM_RUNTIME_H |
11 | |
12 | #include <linux/device.h> |
13 | #include <linux/pm.h> |
14 | |
15 | #ifdef CONFIG_PM_RUNTIME |
16 | |
17 | extern struct workqueue_struct *pm_wq; |
18 | |
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); |
31 | extern void pm_runtime_allow(struct device *dev); |
32 | extern void pm_runtime_forbid(struct device *dev); |
33 | |
34 | static inline bool pm_children_suspended(struct device *dev) |
35 | { |
36 | return dev->power.ignore_children |
37 | || !atomic_read(&dev->power.child_count); |
38 | } |
39 | |
40 | static inline void pm_suspend_ignore_children(struct device *dev, bool enable) |
41 | { |
42 | dev->power.ignore_children = enable; |
43 | } |
44 | |
45 | static inline void pm_runtime_get_noresume(struct device *dev) |
46 | { |
47 | atomic_inc(&dev->power.usage_count); |
48 | } |
49 | |
50 | static inline void pm_runtime_put_noidle(struct device *dev) |
51 | { |
52 | atomic_add_unless(&dev->power.usage_count, -1, 0); |
53 | } |
54 | |
55 | static inline bool device_run_wake(struct device *dev) |
56 | { |
57 | return dev->power.run_wake; |
58 | } |
59 | |
60 | static inline void device_set_run_wake(struct device *dev, bool enable) |
61 | { |
62 | dev->power.run_wake = enable; |
63 | } |
64 | |
65 | static inline bool pm_runtime_suspended(struct device *dev) |
66 | { |
67 | return dev->power.runtime_status == RPM_SUSPENDED; |
68 | } |
69 | |
70 | #else /* !CONFIG_PM_RUNTIME */ |
71 | |
72 | static inline int pm_runtime_idle(struct device *dev) { return -ENOSYS; } |
73 | static inline int pm_runtime_suspend(struct device *dev) { return -ENOSYS; } |
74 | static inline int pm_runtime_resume(struct device *dev) { return 0; } |
75 | static inline int pm_request_idle(struct device *dev) { return -ENOSYS; } |
76 | static inline int pm_schedule_suspend(struct device *dev, unsigned int delay) |
77 | { |
78 | return -ENOSYS; |
79 | } |
80 | static inline int pm_request_resume(struct device *dev) { return 0; } |
81 | static inline int __pm_runtime_get(struct device *dev, bool sync) { return 1; } |
82 | static inline int __pm_runtime_put(struct device *dev, bool sync) { return 0; } |
83 | static inline int __pm_runtime_set_status(struct device *dev, |
84 | unsigned int status) { return 0; } |
85 | static inline int pm_runtime_barrier(struct device *dev) { return 0; } |
86 | static inline void pm_runtime_enable(struct device *dev) {} |
87 | static inline void __pm_runtime_disable(struct device *dev, bool c) {} |
88 | static inline void pm_runtime_allow(struct device *dev) {} |
89 | static inline void pm_runtime_forbid(struct device *dev) {} |
90 | |
91 | static inline bool pm_children_suspended(struct device *dev) { return false; } |
92 | static inline void pm_suspend_ignore_children(struct device *dev, bool en) {} |
93 | static inline void pm_runtime_get_noresume(struct device *dev) {} |
94 | static inline void pm_runtime_put_noidle(struct device *dev) {} |
95 | static inline bool device_run_wake(struct device *dev) { return false; } |
96 | static inline void device_set_run_wake(struct device *dev, bool enable) {} |
97 | static inline bool pm_runtime_suspended(struct device *dev) { return false; } |
98 | |
99 | #endif /* !CONFIG_PM_RUNTIME */ |
100 | |
101 | static inline int pm_runtime_get(struct device *dev) |
102 | { |
103 | return __pm_runtime_get(dev, false); |
104 | } |
105 | |
106 | static inline int pm_runtime_get_sync(struct device *dev) |
107 | { |
108 | return __pm_runtime_get(dev, true); |
109 | } |
110 | |
111 | static inline int pm_runtime_put(struct device *dev) |
112 | { |
113 | return __pm_runtime_put(dev, false); |
114 | } |
115 | |
116 | static inline int pm_runtime_put_sync(struct device *dev) |
117 | { |
118 | return __pm_runtime_put(dev, true); |
119 | } |
120 | |
121 | static inline int pm_runtime_set_active(struct device *dev) |
122 | { |
123 | return __pm_runtime_set_status(dev, RPM_ACTIVE); |
124 | } |
125 | |
126 | static inline void pm_runtime_set_suspended(struct device *dev) |
127 | { |
128 | __pm_runtime_set_status(dev, RPM_SUSPENDED); |
129 | } |
130 | |
131 | static inline void pm_runtime_disable(struct device *dev) |
132 | { |
133 | __pm_runtime_disable(dev, true); |
134 | } |
135 | |
136 | #endif |
137 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9