public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH REPOST] Support enable/disable of WAN module in ibm_acpi
@ 2006-06-01 21:40 Jeremy Fitzhardinge
  2006-06-01 22:25 ` Borislav Deianov
  0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Fitzhardinge @ 2006-06-01 21:40 UTC (permalink / raw)
  To: Borislav Deianov; +Cc: linux-kernel, linux-acpi, Andrew Morton

New Lenovo Thinkpads have an optional WAN module (a Sierra Wireless
MC5720 EV-DO modem), which can be turned on and off much like the
Bluetooth module.  This patch adds a "wan" entry to /proc/acpi/ibm,
which is pretty much a cut'n'paste of the corresponding bluetooth code.

    J

--

Allow a WAN module to enabled/disabled on a Thinkpad X60.

The WAN (Sierra Wireless EV-DO) module is very similar to the
Bluetooth module.  It appears on the USB bus when enabled.  It can be
controlled via hot key, or directly via ACPI.  This change enables
direct control via ACPI.

I have tested it on my Lenovo Thinkpad X60; I guess it will probably
work on other Thinkpad models which come with this module installed.

Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>

diff -r 401a0868b8be drivers/acpi/ibm_acpi.c
--- a/drivers/acpi/ibm_acpi.c	Mon May 29 06:35:52 2006 +0700
+++ b/drivers/acpi/ibm_acpi.c	Mon May 29 01:36:12 2006 -0700
@@ -567,6 +567,69 @@ static int bluetooth_write(char *buf)
 	return 0;
 }
 
+static int wan_supported;
+
+static int wan_init(void)
+{
+	wan_supported = hkey_handle &&
+	    acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
+
+	return 0;
+}
+
+static int wan_status(void)
+{
+	int status;
+
+	if (!wan_supported ||
+	    !acpi_evalf(hkey_handle, &status, "GWAN", "d"))
+		status = 0;
+
+	return status;
+}
+
+static int wan_read(char *p)
+{
+	int len = 0;
+	int status = wan_status();
+
+	if (!wan_supported)
+		len += sprintf(p + len, "status:\t\tnot supported\n");
+	else if (!(status & 1))
+		len += sprintf(p + len, "status:\t\tnot installed\n");
+	else {
+		len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 1));
+		len += sprintf(p + len, "commands:\tenable, disable\n");
+	}
+
+	return len;
+}
+
+static int wan_write(char *buf)
+{
+	int status = wan_status();
+	char *cmd;
+	int do_cmd = 0;
+
+	if (!wan_supported)
+		return -ENODEV;
+
+	while ((cmd = next_cmd(&buf))) {
+		if (strlencmp(cmd, "enable") == 0) {
+			status |= 2;
+		} else if (strlencmp(cmd, "disable") == 0) {
+			status &= ~2;
+		} else
+			return -EINVAL;
+		do_cmd = 1;
+	}
+
+	if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
+		return -EIO;
+
+	return 0;
+}
+
 static int video_supported;
 static int video_orig_autosw;
 
@@ -1561,6 +1624,13 @@ static struct ibm_struct ibms[] = {
 	 .init = bluetooth_init,
 	 .read = bluetooth_read,
 	 .write = bluetooth_write,
+	 },
+	{
+	 .name = "wan",
+	 .init = wan_init,
+	 .read = wan_read,
+	 .write = wan_write,
+	 .experimental = 1,
 	 },
 	{
 	 .name = "video",



^ permalink raw reply	[flat|nested] 3+ messages in thread
* RE: [PATCH REPOST] Support enable/disable of WAN module in ibm_acpi
@ 2006-06-02  0:42 Brown, Len
  0 siblings, 0 replies; 3+ messages in thread
From: Brown, Len @ 2006-06-02  0:42 UTC (permalink / raw)
  To: Borislav Deianov, Jeremy Fitzhardinge
  Cc: linux-kernel, linux-acpi, Andrew Morton

applied to acpi-test.

thanks,
-Len 

>-----Original Message-----
>From: Borislav Deianov [mailto:borislav@users.sf.net] 
>Sent: Thursday, June 01, 2006 6:25 PM
>To: Brown, Len; Jeremy Fitzhardinge
>Cc: linux-kernel@vger.kernel.org; linux-acpi@vger.kernel.org; 
>Andrew Morton
>Subject: Re: [PATCH REPOST] Support enable/disable of WAN 
>module in ibm_acpi
>
>On Thu, Jun 01, 2006 at 02:40:46PM -0700, Jeremy Fitzhardinge wrote:
>> New Lenovo Thinkpads have an optional WAN module (a Sierra Wireless
>> MC5720 EV-DO modem), which can be turned on and off much like the
>> Bluetooth module.  This patch adds a "wan" entry to /proc/acpi/ibm,
>> which is pretty much a cut'n'paste of the corresponding 
>bluetooth code.
>
>I'm not able to test this myself, but it looks good. Len, please
>apply.
>
>Thanks,
>Borislav
>
>--
>
>Allow a WAN module to enabled/disabled on a Thinkpad X60.
>
>The WAN (Sierra Wireless EV-DO) module is very similar to the
>Bluetooth module.  It appears on the USB bus when enabled.  It can be
>controlled via hot key, or directly via ACPI.  This change enables
>direct control via ACPI.
>
>I have tested it on my Lenovo Thinkpad X60; I guess it will probably
>work on other Thinkpad models which come with this module installed.
>
>Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
>
>diff -r 401a0868b8be drivers/acpi/ibm_acpi.c
>--- a/drivers/acpi/ibm_acpi.c	Mon May 29 06:35:52 2006 +0700
>+++ b/drivers/acpi/ibm_acpi.c	Mon May 29 01:36:12 2006 -0700
>@@ -567,6 +567,69 @@ static int bluetooth_write(char *buf)
>	return 0;
>}
>
>+static int wan_supported;
>+
>+static int wan_init(void)
>+{
>+	wan_supported = hkey_handle &&
>+	    acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
>+
>+	return 0;
>+}
>+
>+static int wan_status(void)
>+{
>+	int status;
>+
>+	if (!wan_supported ||
>+	    !acpi_evalf(hkey_handle, &status, "GWAN", "d"))
>+		status = 0;
>+
>+	return status;
>+}
>+
>+static int wan_read(char *p)
>+{
>+	int len = 0;
>+	int status = wan_status();
>+
>+	if (!wan_supported)
>+		len += sprintf(p + len, "status:\t\tnot supported\n");
>+	else if (!(status & 1))
>+		len += sprintf(p + len, "status:\t\tnot installed\n");
>+	else {
>+		len += sprintf(p + len, "status:\t\t%s\n", 
>enabled(status, 
>1));
>+		len += sprintf(p + len, "commands:\tenable, disable\n");
>+	}
>+
>+	return len;
>+}
>+
>+static int wan_write(char *buf)
>+{
>+	int status = wan_status();
>+	char *cmd;
>+	int do_cmd = 0;
>+
>+	if (!wan_supported)
>+		return -ENODEV;
>+
>+	while ((cmd = next_cmd(&buf))) {
>+		if (strlencmp(cmd, "enable") == 0) {
>+			status |= 2;
>+		} else if (strlencmp(cmd, "disable") == 0) {
>+			status &= ~2;
>+		} else
>+			return -EINVAL;
>+		do_cmd = 1;
>+	}
>+
>+	if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SWAN", 
>"vd", status))
>+		return -EIO;
>+
>+	return 0;
>+}
>+
>static int video_supported;
>static int video_orig_autosw;
>
>@@ -1561,6 +1624,13 @@ static struct ibm_struct ibms[] = {
>	 .init = bluetooth_init,
>	 .read = bluetooth_read,
>	 .write = bluetooth_write,
>+	 },
>+	{
>+	 .name = "wan",
>+	 .init = wan_init,
>+	 .read = wan_read,
>+	 .write = wan_write,
>+	 .experimental = 1,
>	 },
>	{
>	 .name = "video",
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-02  0:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-01 21:40 [PATCH REPOST] Support enable/disable of WAN module in ibm_acpi Jeremy Fitzhardinge
2006-06-01 22:25 ` Borislav Deianov
  -- strict thread matches above, loose matches on Subject: below --
2006-06-02  0:42 Brown, Len

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox