| 1 | From 7b236e69bb4403f20fbdef81907d46b4d32d4af8 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?utf-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <arve@android.com> |
| 3 | Date: Thu, 9 Oct 2008 19:17:11 -0700 |
| 4 | Subject: [PATCH 068/134] PM: Enable early suspend through /sys/power/state |
| 5 | |
| 6 | If EARLYSUSPEND is enabled then writes to /sys/power/state no longer |
| 7 | blocks, and the kernel will try to enter the requested state every |
| 8 | time no wakelocks are held. Write "on" to resume normal operation. |
| 9 | --- |
| 10 | kernel/power/main.c | 14 ++++++++++++++ |
| 11 | 1 files changed, 14 insertions(+), 0 deletions(-) |
| 12 | |
| 13 | --- a/kernel/power/main.c |
| 14 | +++ b/kernel/power/main.c |
| 15 | @@ -408,6 +408,9 @@ static void suspend_finish(void) |
| 16 | |
| 17 | |
| 18 | static const char * const pm_states[PM_SUSPEND_MAX] = { |
| 19 | +#ifdef CONFIG_EARLYSUSPEND |
| 20 | + [PM_SUSPEND_ON] = "on", |
| 21 | +#endif |
| 22 | [PM_SUSPEND_STANDBY] = "standby", |
| 23 | [PM_SUSPEND_MEM] = "mem", |
| 24 | }; |
| 25 | @@ -525,7 +528,11 @@ static ssize_t state_store(struct kobjec |
| 26 | const char *buf, size_t n) |
| 27 | { |
| 28 | #ifdef CONFIG_SUSPEND |
| 29 | +#ifdef CONFIG_EARLYSUSPEND |
| 30 | + suspend_state_t state = PM_SUSPEND_ON; |
| 31 | +#else |
| 32 | suspend_state_t state = PM_SUSPEND_STANDBY; |
| 33 | +#endif |
| 34 | const char * const *s; |
| 35 | #endif |
| 36 | char *p; |
| 37 | @@ -547,8 +554,15 @@ static ssize_t state_store(struct kobjec |
| 38 | break; |
| 39 | } |
| 40 | if (state < PM_SUSPEND_MAX && *s) |
| 41 | +#ifdef CONFIG_EARLYSUSPEND |
| 42 | + if (state == PM_SUSPEND_ON || valid_state(state)) { |
| 43 | + error = 0; |
| 44 | + request_suspend_state(state); |
| 45 | + } |
| 46 | +#else |
| 47 | error = enter_state(state); |
| 48 | #endif |
| 49 | +#endif |
| 50 | |
| 51 | Exit: |
| 52 | return error ? error : n; |
| 53 | |