This uses the OLPC EC 0x35/0x25 interface.  

Question:  is simple_strtoul() safe here?

Signed-off-by: Chris Ball <[EMAIL PROTECTED]>
---
 arch/x86/kernel/olpc-pm.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/olpc-pm.c b/arch/x86/kernel/olpc-pm.c
index e99a464..9f0a565 100644
--- a/arch/x86/kernel/olpc-pm.c
+++ b/arch/x86/kernel/olpc-pm.c
@@ -43,6 +43,8 @@
 /* These, and the battery EC commands, should be in an olpc.h. */
 #define EC_WRITE_SCI_MASK 0x1b
 #define EC_READ_SCI_MASK  0x1c
+#define EC_WLAN_ENTER_RESET 0x35
+#define EC_WLAN_LEAVE_RESET 0x25
 
 extern void do_olpc_suspend_lowlevel(void);
 
@@ -661,6 +663,19 @@ static ssize_t wackup_show(struct kobject *s, struct 
kobj_attribute *attr,
        return sprintf(buf, "%s\n", wackup_source ? wackup_source : "none");
 }
 
+static ssize_t wlanreset_execute(struct kobject *s, struct kobj_attribute 
*attr,
+               const char *buf, size_t n)
+{
+       unsigned int val = simple_strtoul(buf, NULL, 0);
+       if (val == 1) {
+               olpc_ec_cmd(EC_WLAN_ENTER_RESET, NULL, 0, NULL, 0);
+       }
+       else if (val == 0) {
+               olpc_ec_cmd(EC_WLAN_LEAVE_RESET, NULL, 0, NULL, 0);
+       }
+       return n;
+}
+
 static struct kobj_attribute control_attr =
        __ATTR(olpc-pm, 0644, control_show, control_store);
 
@@ -670,10 +685,14 @@ static struct kobj_attribute test_attr =
 static struct kobj_attribute wackup_attr =
        __ATTR(wakeup-source, 0400, wackup_show, NULL);
 
+static struct kobj_attribute wlanreset_attr =
+       __ATTR(wlan-reset, 0644, NULL, wlanreset_execute);
+
 static struct attribute * olpc_attributes[] = {
        &control_attr.attr,
        &test_attr.attr,
        &wackup_attr.attr,
+       &wlanreset_attr.attr,
        NULL
 };
 
-- 
1.5.4.3
_______________________________________________
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel

Reply via email to