diff options
| author | Len Brown <len.brown@intel.com> | 2012-04-06 21:48:59 -0400 |
|---|---|---|
| committer | Len Brown <len.brown@intel.com> | 2012-04-06 21:48:59 -0400 |
| commit | eeaab2d8af2cf1d36d7086f22e9de42d6dd2995c (patch) | |
| tree | 369b9c91a6d808944f07d2290fec6f9fe2731904 /kernel/power/suspend.c | |
| parent | ee01e663373343c63e0e3d364d09f6155378dbcc (diff) | |
| parent | aaef292acf3a78d9c0bb6fb72226077d286b45d7 (diff) | |
Merge branches 'idle-fix' and 'misc' into release
Diffstat (limited to 'kernel/power/suspend.c')
| -rw-r--r-- | kernel/power/suspend.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 4fd51beed879..88e5c967370d 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
| @@ -37,8 +37,8 @@ const char *const pm_states[PM_SUSPEND_MAX] = { | |||
| 37 | static const struct platform_suspend_ops *suspend_ops; | 37 | static const struct platform_suspend_ops *suspend_ops; |
| 38 | 38 | ||
| 39 | /** | 39 | /** |
| 40 | * suspend_set_ops - Set the global suspend method table. | 40 | * suspend_set_ops - Set the global suspend method table. |
| 41 | * @ops: Pointer to ops structure. | 41 | * @ops: Suspend operations to use. |
| 42 | */ | 42 | */ |
| 43 | void suspend_set_ops(const struct platform_suspend_ops *ops) | 43 | void suspend_set_ops(const struct platform_suspend_ops *ops) |
| 44 | { | 44 | { |
| @@ -58,11 +58,11 @@ bool valid_state(suspend_state_t state) | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | * suspend_valid_only_mem - generic memory-only valid callback | 61 | * suspend_valid_only_mem - Generic memory-only valid callback. |
| 62 | * | 62 | * |
| 63 | * Platform drivers that implement mem suspend only and only need | 63 | * Platform drivers that implement mem suspend only and only need to check for |
| 64 | * to check for that in their .valid callback can use this instead | 64 | * that in their .valid() callback can use this instead of rolling their own |
| 65 | * of rolling their own .valid callback. | 65 | * .valid() callback. |
| 66 | */ | 66 | */ |
| 67 | int suspend_valid_only_mem(suspend_state_t state) | 67 | int suspend_valid_only_mem(suspend_state_t state) |
| 68 | { | 68 | { |
| @@ -83,10 +83,11 @@ static int suspend_test(int level) | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | /** | 85 | /** |
| 86 | * suspend_prepare - Do prep work before entering low-power state. | 86 | * suspend_prepare - Prepare for entering system sleep state. |
| 87 | * | 87 | * |
| 88 | * This is common code that is called for each state that we're entering. | 88 | * Common code run for every system sleep state that can be entered (except for |
| 89 | * Run suspend notifiers, allocate a console and stop all processes. | 89 | * hibernation). Run suspend notifiers, allocate the "suspend" console and |
| 90 | * freeze processes. | ||
| 90 | */ | 91 | */ |
| 91 | static int suspend_prepare(void) | 92 | static int suspend_prepare(void) |
| 92 | { | 93 | { |
| @@ -131,9 +132,9 @@ void __attribute__ ((weak)) arch_suspend_enable_irqs(void) | |||
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | /** | 134 | /** |
| 134 | * suspend_enter - enter the desired system sleep state. | 135 | * suspend_enter - Make the system enter the given sleep state. |
| 135 | * @state: State to enter | 136 | * @state: System sleep state to enter. |
| 136 | * @wakeup: Returns information that suspend should not be entered again. | 137 | * @wakeup: Returns information that the sleep state should not be re-entered. |
| 137 | * | 138 | * |
| 138 | * This function should be called after devices have been suspended. | 139 | * This function should be called after devices have been suspended. |
| 139 | */ | 140 | */ |
| @@ -147,7 +148,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) | |||
| 147 | goto Platform_finish; | 148 | goto Platform_finish; |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | error = dpm_suspend_noirq(PMSG_SUSPEND); | 151 | error = dpm_suspend_end(PMSG_SUSPEND); |
| 151 | if (error) { | 152 | if (error) { |
| 152 | printk(KERN_ERR "PM: Some devices failed to power down\n"); | 153 | printk(KERN_ERR "PM: Some devices failed to power down\n"); |
| 153 | goto Platform_finish; | 154 | goto Platform_finish; |
| @@ -189,7 +190,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) | |||
| 189 | if (suspend_ops->wake) | 190 | if (suspend_ops->wake) |
| 190 | suspend_ops->wake(); | 191 | suspend_ops->wake(); |
| 191 | 192 | ||
| 192 | dpm_resume_noirq(PMSG_RESUME); | 193 | dpm_resume_start(PMSG_RESUME); |
| 193 | 194 | ||
| 194 | Platform_finish: | 195 | Platform_finish: |
| 195 | if (suspend_ops->finish) | 196 | if (suspend_ops->finish) |
| @@ -199,9 +200,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) | |||
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | /** | 202 | /** |
| 202 | * suspend_devices_and_enter - suspend devices and enter the desired system | 203 | * suspend_devices_and_enter - Suspend devices and enter system sleep state. |
| 203 | * sleep state. | 204 | * @state: System sleep state to enter. |
| 204 | * @state: state to enter | ||
| 205 | */ | 205 | */ |
| 206 | int suspend_devices_and_enter(suspend_state_t state) | 206 | int suspend_devices_and_enter(suspend_state_t state) |
| 207 | { | 207 | { |
| @@ -251,10 +251,10 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | /** | 253 | /** |
| 254 | * suspend_finish - Do final work before exiting suspend sequence. | 254 | * suspend_finish - Clean up before finishing the suspend sequence. |
| 255 | * | 255 | * |
| 256 | * Call platform code to clean up, restart processes, and free the | 256 | * Call platform code to clean up, restart processes, and free the console that |
| 257 | * console that we've allocated. This is not called for suspend-to-disk. | 257 | * we've allocated. This routine is not called for hibernation. |
| 258 | */ | 258 | */ |
| 259 | static void suspend_finish(void) | 259 | static void suspend_finish(void) |
| 260 | { | 260 | { |
| @@ -265,16 +265,14 @@ static void suspend_finish(void) | |||
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | /** | 267 | /** |
| 268 | * enter_state - Do common work of entering low-power state. | 268 | * enter_state - Do common work needed to enter system sleep state. |
| 269 | * @state: pm_state structure for state we're entering. | 269 | * @state: System sleep state to enter. |
| 270 | * | 270 | * |
| 271 | * Make sure we're the only ones trying to enter a sleep state. Fail | 271 | * Make sure that no one else is trying to put the system into a sleep state. |
| 272 | * if someone has beat us to it, since we don't want anything weird to | 272 | * Fail if that's not the case. Otherwise, prepare for system suspend, make the |
| 273 | * happen when we wake up. | 273 | * system enter the given sleep state and clean up after wakeup. |
| 274 | * Then, do the setup for suspend, enter the state, and cleaup (after | ||
| 275 | * we've woken up). | ||
| 276 | */ | 274 | */ |
| 277 | int enter_state(suspend_state_t state) | 275 | static int enter_state(suspend_state_t state) |
| 278 | { | 276 | { |
| 279 | int error; | 277 | int error; |
| 280 | 278 | ||
| @@ -310,24 +308,26 @@ int enter_state(suspend_state_t state) | |||
| 310 | } | 308 | } |
| 311 | 309 | ||
| 312 | /** | 310 | /** |
| 313 | * pm_suspend - Externally visible function for suspending system. | 311 | * pm_suspend - Externally visible function for suspending the system. |
| 314 | * @state: Enumerated value of state to enter. | 312 | * @state: System sleep state to enter. |
| 315 | * | 313 | * |
| 316 | * Determine whether or not value is within range, get state | 314 | * Check if the value of @state represents one of the supported states, |
| 317 | * structure, and enter (above). | 315 | * execute enter_state() and update system suspend statistics. |
| 318 | */ | 316 | */ |
| 319 | int pm_suspend(suspend_state_t state) | 317 | int pm_suspend(suspend_state_t state) |
| 320 | { | 318 | { |
| 321 | int ret; | 319 | int error; |
| 322 | if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) { | 320 | |
| 323 | ret = enter_state(state); | 321 | if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX) |
| 324 | if (ret) { | 322 | return -EINVAL; |
| 325 | suspend_stats.fail++; | 323 | |
| 326 | dpm_save_failed_errno(ret); | 324 | error = enter_state(state); |
| 327 | } else | 325 | if (error) { |
| 328 | suspend_stats.success++; | 326 | suspend_stats.fail++; |
| 329 | return ret; | 327 | dpm_save_failed_errno(error); |
| 328 | } else { | ||
| 329 | suspend_stats.success++; | ||
| 330 | } | 330 | } |
| 331 | return -EINVAL; | 331 | return error; |
| 332 | } | 332 | } |
| 333 | EXPORT_SYMBOL(pm_suspend); | 333 | EXPORT_SYMBOL(pm_suspend); |
