diff options
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r-- | kernel/power/main.c | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index d77663bfedeb..63fbe7347b3e 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -15,6 +15,9 @@ #include <linux/workqueue.h> #include <linux/debugfs.h> #include <linux/seq_file.h> +#include <linux/rtc.h> +#include <linux/syscalls.h> /* sys_sync */ +#include <linux/list.h> #include "power.h" @@ -313,7 +316,7 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr, static suspend_state_t decode_state(const char *buf, size_t n) { #ifdef CONFIG_SUSPEND - suspend_state_t state = PM_SUSPEND_MIN; + suspend_state_t state = PM_SUSPEND_ON; const char * const *s; #endif char *p; @@ -340,7 +343,6 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, { suspend_state_t state; int error; - error = pm_autosleep_lock(); if (error) return error; @@ -349,10 +351,13 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, error = -EBUSY; goto out; } - state = decode_state(buf, n); - if (state < PM_SUSPEND_MAX) - error = pm_suspend(state); + if (state < PM_SUSPEND_MAX) { + if (state == PM_SUSPEND_ON || valid_state(state)) { + error = 0; + request_suspend_state(state); + } + } else if (state == PM_SUSPEND_MAX) error = hibernate(); else @@ -465,7 +470,6 @@ static ssize_t autosleep_store(struct kobject *kobj, if (state == PM_SUSPEND_ON && strcmp(buf, "off") && strcmp(buf, "off\n")) return -EINVAL; - error = pm_autosleep_set_state(state); return error ? error : n; } @@ -474,38 +478,19 @@ power_attr(autosleep); #endif /* CONFIG_PM_AUTOSLEEP */ #ifdef CONFIG_PM_WAKELOCKS -static ssize_t wake_lock_show(struct kobject *kobj, +extern ssize_t wake_lock_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - return pm_show_wakelocks(buf, true); -} - -static ssize_t wake_lock_store(struct kobject *kobj, + char *buf); +extern ssize_t wake_lock_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t n) -{ - int error = pm_wake_lock(buf); - return error ? error : n; -} - + const char *buf, size_t n); power_attr(wake_lock); - -static ssize_t wake_unlock_show(struct kobject *kobj, +extern ssize_t wake_unlock_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - return pm_show_wakelocks(buf, false); -} - -static ssize_t wake_unlock_store(struct kobject *kobj, + char *buf); +extern ssize_t wake_unlock_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t n) -{ - int error = pm_wake_unlock(buf); - return error ? error : n; -} - + const char *buf, size_t n); power_attr(wake_unlock); #endif /* CONFIG_PM_WAKELOCKS */ |