summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeepak Saxena <dsaxena@laptop.org>2008-09-08 16:06:12 -0700
committerDeepak Saxena <dsaxena@laptop.org>2008-09-08 16:09:24 -0700
commit63579b21df15ab743c960e9ef3f9473bf39519f9 (patch)
treed6493eb5198bcd9f1292b25f5f0970cf6da72af1
parente31284e8bd4c73a93fbcc36916634b1f1c123c2b (diff)
downloadlwn-63579b21df15ab743c960e9ef3f9473bf39519f9.tar.gz
lwn-63579b21df15ab743c960e9ef3f9473bf39519f9.zip
Add interface to enable/disable all wakeup events from sysfs
As per OLPC trac #7981, we need a fastpath method to enable/disable all events via a single EC command to decrease resume latency time. This patch adds an "all" file to /sys/power/wakeup_events that provides this capability. Writing 1 to this file will enable all SCI events, writing 0 will disable them all. Signed-off-by: Deepak Saxena <dsaxena@laptop.org>
-rw-r--r--arch/x86/kernel/olpc-pm.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/x86/kernel/olpc-pm.c b/arch/x86/kernel/olpc-pm.c
index acedefbba498..9532a5b16b60 100644
--- a/arch/x86/kernel/olpc-pm.c
+++ b/arch/x86/kernel/olpc-pm.c
@@ -711,6 +711,9 @@ static struct attribute_group olpc_attrs = {
static ssize_t wackup_event_show(struct kobject *s, struct kobj_attribute *attr, char *buf);
static ssize_t wackup_event_store(struct kobject *s, struct kobj_attribute *attr, const char *buf, size_t n);
+static ssize_t wackup_all_show(struct kobject *s, struct kobj_attribute *attr, char *buf);
+static ssize_t wackup_all_store(struct kobject *s, struct kobj_attribute *attr, const char *buf, size_t n);
+
static struct kobj_attribute wackup_event_attr[] = {
__ATTR(ps2event, 0600, wackup_event_show, wackup_event_store),
__ATTR(battery_state, 0600, wackup_event_show, wackup_event_store),
@@ -719,6 +722,7 @@ static struct kobj_attribute wackup_event_attr[] = {
__ATTR(ebook_mode_change, 0600, wackup_event_show, wackup_event_store),
__ATTR(wlan, 0600, wackup_event_show, wackup_event_store),
__ATTR(ac_power, 0600, wackup_event_show, wackup_event_store),
+ __ATTR(all, 0600, wackup_all_show, wackup_all_store)
};
static DEFINE_RWLOCK(wackup_event_lock);
@@ -758,6 +762,43 @@ static ssize_t wackup_event_store(struct kobject *s, struct kobj_attribute *attr
return n;
}
+static ssize_t wackup_all_show(struct kobject *s, struct kobj_attribute *attr, char *buf)
+{
+ u8 data;
+
+ read_lock(&wackup_event_lock);
+ olpc_ec_cmd(EC_READ_SCI_MASK, NULL, 0, &data, 1);
+ read_unlock(&wackup_event_lock);
+
+ if (data == 0xff)
+ return sprintf(buf, "1\n");
+ else
+ return sprintf(buf, "0\n");
+}
+
+static ssize_t wackup_all_store(struct kobject *s, struct kobj_attribute *attr, const char *buf, size_t n)
+{
+ unsigned enabled;
+ u8 data;
+ unsigned char shift = attr - wackup_event_attr;
+
+ if (sscanf(buf, "%d\n", &enabled) != 1)
+ return -EINVAL;
+
+ if (enabled == 1)
+ data = 0xff;
+ else if (!enabled)
+ data = 0;
+ else
+ return -EINVAL;
+
+ write_lock(&wackup_event_lock);
+ olpc_ec_cmd(EC_WRITE_SCI_MASK, &data, 1, NULL, 0);
+ write_unlock(&wackup_event_lock);
+
+ return n;
+}
+
static struct attribute * olpc_wackup_event_attributes[] = {
&wackup_event_attr[0].attr,
&wackup_event_attr[1].attr,
@@ -766,6 +807,7 @@ static struct attribute * olpc_wackup_event_attributes[] = {
&wackup_event_attr[4].attr,
&wackup_event_attr[5].attr,
&wackup_event_attr[6].attr,
+ &wackup_event_attr[7].attr,
NULL
};