diff options
Diffstat (limited to 'include/linux/pm_runtime.h')
| -rw-r--r-- | include/linux/pm_runtime.h | 121 | 
1 files changed, 103 insertions, 18 deletions
| diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index 6e81888c6222..3ec2358f8692 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h | |||
| @@ -12,18 +12,24 @@ | |||
| 12 | #include <linux/device.h> | 12 | #include <linux/device.h> | 
| 13 | #include <linux/pm.h> | 13 | #include <linux/pm.h> | 
| 14 | 14 | ||
| 15 | #include <linux/jiffies.h> | ||
| 16 | |||
| 17 | /* Runtime PM flag argument bits */ | ||
| 18 | #define RPM_ASYNC 0x01 /* Request is asynchronous */ | ||
| 19 | #define RPM_NOWAIT 0x02 /* Don't wait for concurrent | ||
| 20 | state change */ | ||
| 21 | #define RPM_GET_PUT 0x04 /* Increment/decrement the | ||
| 22 | usage_count */ | ||
| 23 | #define RPM_AUTO 0x08 /* Use autosuspend_delay */ | ||
| 24 | |||
| 15 | #ifdef CONFIG_PM_RUNTIME | 25 | #ifdef CONFIG_PM_RUNTIME | 
| 16 | 26 | ||
| 17 | extern struct workqueue_struct *pm_wq; | 27 | extern struct workqueue_struct *pm_wq; | 
| 18 | 28 | ||
| 19 | extern int pm_runtime_idle(struct device *dev); | 29 | extern int __pm_runtime_idle(struct device *dev, int rpmflags); | 
| 20 | extern int pm_runtime_suspend(struct device *dev); | 30 | extern int __pm_runtime_suspend(struct device *dev, int rpmflags); | 
| 21 | extern int pm_runtime_resume(struct device *dev); | 31 | extern int __pm_runtime_resume(struct device *dev, int rpmflags); | 
| 22 | extern int pm_request_idle(struct device *dev); | ||
| 23 | extern int pm_schedule_suspend(struct device *dev, unsigned int delay); | 32 | 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); | 33 | extern int __pm_runtime_set_status(struct device *dev, unsigned int status); | 
| 28 | extern int pm_runtime_barrier(struct device *dev); | 34 | extern int pm_runtime_barrier(struct device *dev); | 
| 29 | extern void pm_runtime_enable(struct device *dev); | 35 | extern void pm_runtime_enable(struct device *dev); | 
| @@ -33,6 +39,10 @@ extern void pm_runtime_forbid(struct device *dev); | |||
| 33 | extern int pm_generic_runtime_idle(struct device *dev); | 39 | extern int pm_generic_runtime_idle(struct device *dev); | 
| 34 | extern int pm_generic_runtime_suspend(struct device *dev); | 40 | extern int pm_generic_runtime_suspend(struct device *dev); | 
| 35 | extern int pm_generic_runtime_resume(struct device *dev); | 41 | extern int pm_generic_runtime_resume(struct device *dev); | 
| 42 | extern void pm_runtime_no_callbacks(struct device *dev); | ||
| 43 | extern void __pm_runtime_use_autosuspend(struct device *dev, bool use); | ||
| 44 | extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay); | ||
| 45 | extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev); | ||
| 36 | 46 | ||
| 37 | static inline bool pm_children_suspended(struct device *dev) | 47 | static inline bool pm_children_suspended(struct device *dev) | 
| 38 | { | 48 | { | 
| @@ -70,19 +80,29 @@ static inline bool pm_runtime_suspended(struct device *dev) | |||
| 70 | return dev->power.runtime_status == RPM_SUSPENDED; | 80 | return dev->power.runtime_status == RPM_SUSPENDED; | 
| 71 | } | 81 | } | 
| 72 | 82 | ||
| 83 | static inline void pm_runtime_mark_last_busy(struct device *dev) | ||
| 84 | { | ||
| 85 | ACCESS_ONCE(dev->power.last_busy) = jiffies; | ||
| 86 | } | ||
| 87 | |||
| 73 | #else /* !CONFIG_PM_RUNTIME */ | 88 | #else /* !CONFIG_PM_RUNTIME */ | 
| 74 | 89 | ||
| 75 | static inline int pm_runtime_idle(struct device *dev) { return -ENOSYS; } | 90 | static inline int __pm_runtime_idle(struct device *dev, int rpmflags) | 
| 76 | static inline int pm_runtime_suspend(struct device *dev) { return -ENOSYS; } | 91 | { | 
| 77 | static inline int pm_runtime_resume(struct device *dev) { return 0; } | 92 | return -ENOSYS; | 
| 78 | static inline int pm_request_idle(struct device *dev) { return -ENOSYS; } | 93 | } | 
| 94 | static inline int __pm_runtime_suspend(struct device *dev, int rpmflags) | ||
| 95 | { | ||
| 96 | return -ENOSYS; | ||
| 97 | } | ||
| 98 | static inline int __pm_runtime_resume(struct device *dev, int rpmflags) | ||
| 99 | { | ||
| 100 | return 1; | ||
| 101 | } | ||
| 79 | static inline int pm_schedule_suspend(struct device *dev, unsigned int delay) | 102 | static inline int pm_schedule_suspend(struct device *dev, unsigned int delay) | 
| 80 | { | 103 | { | 
| 81 | return -ENOSYS; | 104 | return -ENOSYS; | 
| 82 | } | 105 | } | 
| 83 | static inline int pm_request_resume(struct device *dev) { return 0; } | ||
| 84 | static inline int __pm_runtime_get(struct device *dev, bool sync) { return 1; } | ||
| 85 | static inline int __pm_runtime_put(struct device *dev, bool sync) { return 0; } | ||
| 86 | static inline int __pm_runtime_set_status(struct device *dev, | 106 | static inline int __pm_runtime_set_status(struct device *dev, | 
| 87 | unsigned int status) { return 0; } | 107 | unsigned int status) { return 0; } | 
| 88 | static inline int pm_runtime_barrier(struct device *dev) { return 0; } | 108 | static inline int pm_runtime_barrier(struct device *dev) { return 0; } | 
| @@ -102,27 +122,82 @@ static inline bool pm_runtime_suspended(struct device *dev) { return false; } | |||
| 102 | static inline int pm_generic_runtime_idle(struct device *dev) { return 0; } | 122 | static inline int pm_generic_runtime_idle(struct device *dev) { return 0; } | 
| 103 | static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; } | 123 | static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; } | 
| 104 | static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } | 124 | static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } | 
| 125 | static inline void pm_runtime_no_callbacks(struct device *dev) {} | ||
| 126 | |||
| 127 | static inline void pm_runtime_mark_last_busy(struct device *dev) {} | ||
| 128 | static inline void __pm_runtime_use_autosuspend(struct device *dev, | ||
| 129 | bool use) {} | ||
| 130 | static inline void pm_runtime_set_autosuspend_delay(struct device *dev, | ||
| 131 | int delay) {} | ||
| 132 | static inline unsigned long pm_runtime_autosuspend_expiration( | ||
| 133 | struct device *dev) { return 0; } | ||
| 105 | 134 | ||
| 106 | #endif /* !CONFIG_PM_RUNTIME */ | 135 | #endif /* !CONFIG_PM_RUNTIME */ | 
| 107 | 136 | ||
| 137 | static inline int pm_runtime_idle(struct device *dev) | ||
| 138 | { | ||
| 139 | return __pm_runtime_idle(dev, 0); | ||
| 140 | } | ||
| 141 | |||
| 142 | static inline int pm_runtime_suspend(struct device *dev) | ||
| 143 | { | ||
| 144 | return __pm_runtime_suspend(dev, 0); | ||
| 145 | } | ||
| 146 | |||
| 147 | static inline int pm_runtime_autosuspend(struct device *dev) | ||
| 148 | { | ||
| 149 | return __pm_runtime_suspend(dev, RPM_AUTO); | ||
| 150 | } | ||
| 151 | |||
| 152 | static inline int pm_runtime_resume(struct device *dev) | ||
| 153 | { | ||
| 154 | return __pm_runtime_resume(dev, 0); | ||
| 155 | } | ||
| 156 | |||
| 157 | static inline int pm_request_idle(struct device *dev) | ||
| 158 | { | ||
| 159 | return __pm_runtime_idle(dev, RPM_ASYNC); | ||
| 160 | } | ||
| 161 | |||
| 162 | static inline int pm_request_resume(struct device *dev) | ||
| 163 | { | ||
| 164 | return __pm_runtime_resume(dev, RPM_ASYNC); | ||
| 165 | } | ||
| 166 | |||
| 167 | static inline int pm_request_autosuspend(struct device *dev) | ||
| 168 | { | ||
| 169 | return __pm_runtime_suspend(dev, RPM_ASYNC | RPM_AUTO); | ||
| 170 | } | ||
| 171 | |||
| 108 | static inline int pm_runtime_get(struct device *dev) | 172 | static inline int pm_runtime_get(struct device *dev) | 
| 109 | { | 173 | { | 
| 110 | return __pm_runtime_get(dev, false); | 174 | return __pm_runtime_resume(dev, RPM_GET_PUT | RPM_ASYNC); | 
| 111 | } | 175 | } | 
| 112 | 176 | ||
| 113 | static inline int pm_runtime_get_sync(struct device *dev) | 177 | static inline int pm_runtime_get_sync(struct device *dev) | 
| 114 | { | 178 | { | 
| 115 | return __pm_runtime_get(dev, true); | 179 | return __pm_runtime_resume(dev, RPM_GET_PUT); | 
| 116 | } | 180 | } | 
| 117 | 181 | ||
| 118 | static inline int pm_runtime_put(struct device *dev) | 182 | static inline int pm_runtime_put(struct device *dev) | 
| 119 | { | 183 | { | 
| 120 | return __pm_runtime_put(dev, false); | 184 | return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC); | 
| 185 | } | ||
| 186 | |||
| 187 | static inline int pm_runtime_put_autosuspend(struct device *dev) | ||
| 188 | { | ||
| 189 | return __pm_runtime_suspend(dev, | ||
| 190 | RPM_GET_PUT | RPM_ASYNC | RPM_AUTO); | ||
| 121 | } | 191 | } | 
| 122 | 192 | ||
| 123 | static inline int pm_runtime_put_sync(struct device *dev) | 193 | static inline int pm_runtime_put_sync(struct device *dev) | 
| 124 | { | 194 | { | 
| 125 | return __pm_runtime_put(dev, true); | 195 | return __pm_runtime_idle(dev, RPM_GET_PUT); | 
| 196 | } | ||
| 197 | |||
| 198 | static inline int pm_runtime_put_sync_autosuspend(struct device *dev) | ||
| 199 | { | ||
| 200 | return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO); | ||
| 126 | } | 201 | } | 
| 127 | 202 | ||
| 128 | static inline int pm_runtime_set_active(struct device *dev) | 203 | static inline int pm_runtime_set_active(struct device *dev) | 
| @@ -140,4 +215,14 @@ static inline void pm_runtime_disable(struct device *dev) | |||
| 140 | __pm_runtime_disable(dev, true); | 215 | __pm_runtime_disable(dev, true); | 
| 141 | } | 216 | } | 
| 142 | 217 | ||
| 218 | static inline void pm_runtime_use_autosuspend(struct device *dev) | ||
| 219 | { | ||
| 220 | __pm_runtime_use_autosuspend(dev, true); | ||
| 221 | } | ||
| 222 | |||
| 223 | static inline void pm_runtime_dont_use_autosuspend(struct device *dev) | ||
| 224 | { | ||
| 225 | __pm_runtime_use_autosuspend(dev, false); | ||
| 226 | } | ||
| 227 | |||
| 143 | #endif | 228 | #endif | 
