PM: Enable early suspend through /sys/power/state
authorArve Hjønnevåg <arve@android.com>
Fri, 10 Oct 2008 02:17:11 +0000 (19:17 -0700)
committerArve Hjønnevåg <arve@android.com>
Thu, 4 Feb 2010 05:27:05 +0000 (21:27 -0800)
If EARLYSUSPEND is enabled then writes to /sys/power/state no longer
blocks, and the kernel will try to enter the requested state every
time no wakelocks are held. Write "on" to resume normal operation.

kernel/power/main.c
kernel/power/suspend.c

index 347d2cc88cd0e1a824f1004c4288d5d4a8e2959c..77a3584d253f4e9901e1d6dacdc77a348c69dfab 100644 (file)
@@ -147,7 +147,11 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
                           const char *buf, size_t n)
 {
 #ifdef CONFIG_SUSPEND
+#ifdef CONFIG_EARLYSUSPEND
+       suspend_state_t state = PM_SUSPEND_ON;
+#else
        suspend_state_t state = PM_SUSPEND_STANDBY;
+#endif
        const char * const *s;
 #endif
        char *p;
@@ -169,7 +173,14 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
                        break;
        }
        if (state < PM_SUSPEND_MAX && *s)
+#ifdef CONFIG_EARLYSUSPEND
+               if (state == PM_SUSPEND_ON || valid_state(state)) {
+                       error = 0;
+                       request_suspend_state(state);
+               }
+#else
                error = enter_state(state);
+#endif
 #endif
 
  Exit:
index 6f10dfc2d3e9f79a0a57cd73b8a70ad2cc90d22b..cd515ba1c8ce976f340da0c5aab7a0cd7447cdb0 100644 (file)
@@ -19,6 +19,9 @@
 #include "power.h"
 
 const char *const pm_states[PM_SUSPEND_MAX] = {
+#ifdef CONFIG_EARLYSUSPEND
+       [PM_SUSPEND_ON]         = "on",
+#endif
        [PM_SUSPEND_STANDBY]    = "standby",
        [PM_SUSPEND_MEM]        = "mem",
 };