public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Janne Grunau <j@jannau.net>
To: acpi4asus-user@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, Corentin Chary <corentincj@iksaif.net>
Subject: [PATCH 2/2] eeepc-laptop: add rfkill support for the 3G modem in Eee PC 901 Go
Date: Sat, 13 Jun 2009 00:33:26 +0200	[thread overview]
Message-ID: <20090612223326.GF14878@aniel.lan> (raw)
In-Reply-To: <cover.1244845758.git.j@jannau.net>

Signed-off-by: Janne Grunau <j@jannau.net>
---
 drivers/platform/x86/eeepc-laptop.c |   56 +++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 8d1ecc0..288a4c8 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -132,6 +132,7 @@ struct eeepc_hotk {
 	u16 *keycode_map;
 	struct rfkill *eeepc_wlan_rfkill;
 	struct rfkill *eeepc_bluetooth_rfkill;
+	struct rfkill *eeepc_wwan3g_rfkill;
 	struct hotplug_slot *hotplug_slot;
 };
 
@@ -352,6 +353,23 @@ static void __init eeepc_enable_camera(void)
 	set_acpi(CM_ASL_CAMERA, 1);
 }
 
+static int eeepc_wwan3g_rfkill_set(void *data, enum rfkill_state state)
+{
+	if (state == RFKILL_STATE_SOFT_BLOCKED)
+		return set_acpi(CM_ASL_3G, 0);
+	else
+		return set_acpi(CM_ASL_3G, 1);
+}
+
+static int eeepc_wwan3g_rfkill_state(void *data, enum rfkill_state *state)
+{
+	if (get_acpi(CM_ASL_3G) == 1)
+		*state = RFKILL_STATE_UNBLOCKED;
+	else
+		*state = RFKILL_STATE_SOFT_BLOCKED;
+	return 0;
+}
+
 /*
  * Sys helpers
  */
@@ -869,6 +887,35 @@ static int eeepc_hotk_add(struct acpi_device *device)
 			goto bluetooth_fail;
 	}
 
+	if (get_acpi(CM_ASL_3G) != -1) {
+		ehotk->eeepc_wwan3g_rfkill =
+			rfkill_allocate(&device->dev, RFKILL_TYPE_WWAN);
+
+		if (!ehotk->eeepc_wwan3g_rfkill)
+			goto wwan_fail;
+
+		ehotk->eeepc_wwan3g_rfkill->name = "eeepc-3g";
+		ehotk->eeepc_wwan3g_rfkill->toggle_radio =
+			eeepc_wwan3g_rfkill_set;
+		ehotk->eeepc_wwan3g_rfkill->get_state =
+			eeepc_wwan3g_rfkill_state;
+		if (get_acpi(CM_ASL_3G) == 1) {
+			ehotk->eeepc_wwan3g_rfkill->state =
+				RFKILL_STATE_UNBLOCKED;
+			rfkill_set_default(RFKILL_TYPE_WWAN,
+					   RFKILL_STATE_UNBLOCKED);
+		} else {
+			ehotk->eeepc_wwan3g_rfkill->state =
+				RFKILL_STATE_SOFT_BLOCKED;
+			rfkill_set_default(RFKILL_TYPE_WWAN,
+					   RFKILL_STATE_SOFT_BLOCKED);
+		}
+
+		result = rfkill_register(ehotk->eeepc_wwan3g_rfkill);
+		if (result)
+			goto wwan_fail;
+	}
+
 	result = eeepc_setup_pci_hotplug();
 	/*
 	 * If we get -EBUSY then something else is handling the PCI hotplug -
@@ -882,6 +929,13 @@ static int eeepc_hotk_add(struct acpi_device *device)
 	return 0;
 
  pci_fail:
+	if (ehotk->eeepc_wwan3g_rfkill)
+		rfkill_unregister(ehotk->eeepc_wwan3g_rfkill);
+wwan_fail:
+	if (ehotk->eeepc_wwan3g_rfkill) {
+		rfkill_free(ehotk->eeepc_wwan3g_rfkill);
+		ehotk->eeepc_wwan3g_rfkill = NULL;
+	}
 	if (ehotk->eeepc_bluetooth_rfkill)
 		rfkill_unregister(ehotk->eeepc_bluetooth_rfkill);
  bluetooth_fail:
@@ -1041,6 +1095,8 @@ static void eeepc_rfkill_exit(void)
 		rfkill_unregister(ehotk->eeepc_wlan_rfkill);
 	if (ehotk->eeepc_bluetooth_rfkill)
 		rfkill_unregister(ehotk->eeepc_bluetooth_rfkill);
+	if (ehotk->eeepc_wwan3g_rfkill)
+		rfkill_unregister(ehotk->eeepc_wwan3g_rfkill);
 }
 
 static void eeepc_input_exit(void)
-- 
1.6.0.4

      parent reply	other threads:[~2009-06-12 22:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1244845758.git.j@jannau.net>
2009-06-12 22:33 ` [PATCH 1/2] eeepc-laptop: add 3G and Wimax CM_ASL values and acpi method names Janne Grunau
2009-06-12 22:33 ` Janne Grunau [this message]

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=20090612223326.GF14878@aniel.lan \
    --to=j@jannau.net \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=corentincj@iksaif.net \
    --cc=linux-kernel@vger.kernel.org \
    /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