public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Yanovich <ynvich@gmail.com>
To: linux-acpi@vger.kernel.org
Cc: malattia@linux.it, Sergey Yanovich <ynvich@gmail.com>
Subject: [PATCH] acpi: add control over wifi power in Sony laptops
Date: Tue, 29 Apr 2008 16:36:49 +0300	[thread overview]
Message-ID: <1209476209-7809-1-git-send-email-ynvich@gmail.com> (raw)
In-Reply-To: <1208558495-22792-2-git-send-email-ynvich@gmail.com>
In-Reply-To: <1208558495-22792-2-git-send-email-ynvich@gmail.com>

Sony laptops have a single hardware rfkill switch, which controls
several wireless devices: wifi, bluetooth, wwan. The code to
selectively control bluetooth and wwan is already present. This
paths adds handling of wifi.

Signed-off-by: Sergey Yanovich <ynvich@gmail.com>
---
 drivers/misc/sony-laptop.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index be70153..e5b8709 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -1227,6 +1227,7 @@ struct sony_pic_dev {
 	u8			camera_power;
 	u8			bluetooth_power;
 	u8			wwan_power;
+	u8			wifi_power;
 };
 
 static struct sony_pic_dev spic_dev = {
@@ -1760,6 +1761,7 @@ static void sony_pic_set_wwanpower(u8 state)
 		return;
 	}
 	sony_pic_call2(0xB0, state);
+	sony_pic_call1(0x82);
 	spic_dev.wwan_power = state;
 	mutex_unlock(&spic_dev.lock);
 }
@@ -1788,6 +1790,44 @@ static ssize_t sony_pic_wwanpower_show(struct device *dev,
 	return count;
 }
 
+/* wifi power (TX series) */
+static void sony_pic_set_wifipower(u8 state)
+{
+	state = !!state;
+	mutex_lock(&spic_dev.lock);
+	if (spic_dev.wifi_power == state) {
+		mutex_unlock(&spic_dev.lock);
+		return;
+	}
+	sony_pic_call2(0x98, -state);
+	sony_pic_call1(0x82);
+	spic_dev.wifi_power = state;
+	mutex_unlock(&spic_dev.lock);
+}
+
+static ssize_t sony_pic_wifipower_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buffer, size_t count)
+{
+	unsigned long value;
+	if (!strict_strtoul(buffer, 10, &value))
+		return -EINVAL;
+
+	sony_pic_set_wifipower(value);
+
+	return count;
+}
+
+static ssize_t sony_pic_wifipower_show(struct device *dev,
+		struct device_attribute *attr, char *buffer)
+{
+	ssize_t count;
+	mutex_lock(&spic_dev.lock);
+	count = snprintf(buffer, PAGE_SIZE, "%d\n", spic_dev.wifi_power);
+	mutex_unlock(&spic_dev.lock);
+	return count;
+}
+
 /* bluetooth subsystem power state */
 static void __sony_pic_set_bluetoothpower(u8 state)
 {
@@ -1870,11 +1910,13 @@ struct device_attribute spic_attr_##_name = __ATTR(_name,	\
 
 static SPIC_ATTR(bluetoothpower, 0644);
 static SPIC_ATTR(wwanpower, 0644);
+static SPIC_ATTR(wifipower, 0644);
 static SPIC_ATTR(fanspeed, 0644);
 
 static struct attribute *spic_attributes[] = {
 	&spic_attr_bluetoothpower.attr,
 	&spic_attr_wwanpower.attr,
+	&spic_attr_wifipower.attr,
 	&spic_attr_fanspeed.attr,
 	NULL
 };
-- 
1.5.5.1


  parent reply	other threads:[~2008-04-29 13:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-18 22:41 [PATCH 1/3] Correctly detect Sony TX770P PIC device type Sergey Yanovich
2008-04-18 22:41 ` [PATCH 2/3] Add control over wifi power in Sony laptops Sergey Yanovich
2008-04-18 22:41   ` [PATCH 3/3] Synchronize wireless power state with hardware for " Sergey Yanovich
2008-04-18 23:45     ` Sergey Yanovich
2008-04-18 23:51       ` Sergey Yanovich
2008-04-29 13:38         ` [PATCH] acpi: synchronize wireless power state " Sergey Yanovich
2008-04-18 23:59     ` [PATCH 3/3] Synchronize wireless power state with hardware " Sergey Yanovich
2008-04-29 13:36   ` Sergey Yanovich [this message]
2008-04-27  6:15 ` [PATCH 1/3] Correctly detect Sony TX770P PIC device type Mattia Dongili
2008-04-29  8:52   ` Sergey Yanovich
2008-04-29 11:45     ` Mattia Dongili

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1209476209-7809-1-git-send-email-ynvich@gmail.com \
    --to=ynvich@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=malattia@linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox