From: Mario Limonciello <mario_limonciello@dell.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Alan Jenkins <sourcejedi.lkml@googlemail.com>,
Marcel Holtmann <marcel@holtmann.org>,
cezary.jackiewicz@gmail.com, linux-acpi@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH 2/3] Add rfkill support to compal-laptop
Date: Wed, 19 Aug 2009 11:46:36 -0500 [thread overview]
Message-ID: <4A8C2C6C.2020007@dell.com> (raw)
In-Reply-To: <1250672475.25419.7.camel@johannes.local>
[-- Attachment #1.1: Type: text/plain, Size: 1164 bytes --]
Hi Johannes:
Thanks for looking.
Johannes Berg wrote:
> Ah, heh, thanks Alan for pointing out there was a patch here :)
>
>
>
> I don't quite understand the "| radio" bit since that seems to be the
> soft kill bit according to rfkill_set()?
>
Yeah you're right, this bit was unnecessary. I pulled it out.
> Anyhow, here you reject the request to set the soft bit. I suspect you
> could let it go through but it would only change the soft bit in the
> BIOS, nothing else really.
>
> Two options:
> 1) You can let it go though, in that case do that, and remove the sw
> block stuff from poll() completely.
>
> 2) You can't let it go through. In this case, you need to leave set as
> it is, but implement poll like this:
>
> sw_block = rfkill_set_hw_state(rfkill, hw_blocked);
> compal_rfkill_set(data, sw_block);
>
> so that when the user soft-blocks the device while hard-blocked, the
> soft block is still honoured after pushing the button on the laptop.
>
>
OK, the second option sounds more desirable, so I've implemented that.
--
Mario Limonciello
*Dell | Linux Engineering*
mario_limonciello@dell.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 02_add_rfkill_support.diff --]
[-- Type: text/x-patch; name="02_add_rfkill_support.diff", Size: 3952 bytes --]
From 5f5dc9c1adf041418c6dd273cd4ee83d5ae96e74 Mon Sep 17 00:00:00 2001
From: Mario Limonciello <Mario_Limonciello@Dell.com>
Date: Wed, 19 Aug 2009 11:41:27 -0500
Subject: [PATCH 2/3] Add rfkill support to compal-laptop
Signed-off-by: Mario Limonciello <Mario_Limonciello@Dell.com>
Reviewed-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
---
drivers/platform/x86/compal-laptop.c | 91 +++++++++++++++++++++++++++++++++-
1 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
index 11003bb..d997de5 100644
--- a/drivers/platform/x86/compal-laptop.c
+++ b/drivers/platform/x86/compal-laptop.c
@@ -52,6 +52,7 @@
#include <linux/backlight.h>
#include <linux/platform_device.h>
#include <linux/autoconf.h>
+#include <linux/rfkill.h>
#define COMPAL_DRIVER_VERSION "0.2.6"
@@ -64,6 +65,10 @@
#define WLAN_MASK 0x01
#define BT_MASK 0x02
+static struct rfkill *wifi_rfkill;
+static struct rfkill *bt_rfkill;
+static struct platform_device *compal_device;
+
static int force;
module_param(force, bool, 0);
MODULE_PARM_DESC(force, "Force driver load, ignore DMI data");
@@ -89,6 +94,82 @@ static int get_lcd_level(void)
return (int) result;
}
+static int compal_rfkill_set(void *data, bool blocked)
+{
+ unsigned long radio = (unsigned long) data;
+ u8 result, value;
+
+ ec_read(COMPAL_EC_COMMAND_WIRELESS, &result);
+
+ if ((result & KILLSWITCH_MASK) == 0)
+ return -EINVAL;
+
+ if (!blocked)
+ value = (u8) (result | radio);
+ else
+ value = (u8) (result & ~radio);
+ ec_write(COMPAL_EC_COMMAND_WIRELESS, value);
+
+ return 0;
+}
+
+static void compal_rfkill_poll(struct rfkill *rfkill, void *data)
+{
+ u8 result;
+ bool hw_blocked;
+ bool sw_blocked;
+
+ ec_read(COMPAL_EC_COMMAND_WIRELESS, &result);
+
+ hw_blocked = !(result & KILLSWITCH_MASK);
+ sw_blocked = rfkill_set_hw_state(rfkill, hw_blocked);
+ compal_rfkill_set(data,sw_blocked);
+}
+
+static const struct rfkill_ops compal_rfkill_ops = {
+ .poll = compal_rfkill_poll,
+ .set_block = compal_rfkill_set,
+};
+
+static int setup_rfkill(void)
+{
+ int ret;
+
+ wifi_rfkill = rfkill_alloc("compal-wifi", &compal_device->dev,
+ RFKILL_TYPE_WLAN, &compal_rfkill_ops,
+ (void *) WLAN_MASK);
+ if (!wifi_rfkill)
+ return -ENOMEM;
+
+ ret = rfkill_register(wifi_rfkill);
+ if (ret)
+ goto err_wifi;
+
+ bt_rfkill = rfkill_alloc("compal-bluetooth", &compal_device->dev,
+ RFKILL_TYPE_BLUETOOTH, &compal_rfkill_ops,
+ (void *) BT_MASK);
+ if (!bt_rfkill) {
+ ret = -ENOMEM;
+ goto err_allocate_bt;
+ }
+ ret = rfkill_register(bt_rfkill);
+ if (ret)
+ goto err_register_bt;
+
+ return 0;
+
+err_register_bt:
+ rfkill_destroy(bt_rfkill);
+
+err_allocate_bt:
+ rfkill_unregister(wifi_rfkill);
+
+err_wifi:
+ rfkill_destroy(wifi_rfkill);
+
+ return ret;
+}
+
static int set_wlan_state(int state)
{
u8 result, value;
@@ -258,8 +339,6 @@ static struct platform_driver compal_driver = {
}
};
-static struct platform_device *compal_device;
-
/* Initialization */
static int dmi_check_cb(const struct dmi_system_id *id)
@@ -356,6 +435,10 @@ static int __init compal_init(void)
if (ret)
goto fail_platform_device2;
+ ret = setup_rfkill();
+ if (ret)
+ printk(KERN_WARNING "compal-laptop: Unable to setup rfkill\n");
+
printk(KERN_INFO "compal-laptop: driver "COMPAL_DRIVER_VERSION
" successfully loaded.\n");
@@ -387,6 +470,10 @@ static void __exit compal_cleanup(void)
platform_device_unregister(compal_device);
platform_driver_unregister(&compal_driver);
backlight_device_unregister(compalbl_device);
+ rfkill_unregister(wifi_rfkill);
+ rfkill_destroy(wifi_rfkill);
+ rfkill_unregister(bt_rfkill);
+ rfkill_destroy(bt_rfkill);
printk(KERN_INFO "compal-laptop: driver unloaded.\n");
}
--
1.6.3.3
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next prev parent reply other threads:[~2009-08-19 16:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4A89E768.7010207@dell.com>
[not found] ` <1250558643.30166.109.camel@localhost.localdomain>
[not found] ` <9b2b86520908180044l72cb8642j6256e246662f7971@mail.gmail.com>
[not found] ` <9b2b86520908180752k66feda09rf9034a96ac6ef470@mail.gmail.com>
[not found] ` <4A8AE459.8060102@dell.com>
2009-08-18 21:08 ` [PATCH 2/3] Add rfkill support to compal-laptop Alan Jenkins
2009-08-18 21:31 ` Johannes Berg
2009-08-18 22:00 ` Mario Limonciello
2009-08-19 8:51 ` Alan Jenkins
2009-08-19 9:01 ` Johannes Berg
2009-08-19 11:43 ` Cezary Jackiewicz
2009-08-19 16:46 ` Mario Limonciello [this message]
2009-08-19 16:57 ` Alan Jenkins
2009-08-19 17:13 ` Johannes Berg
2009-08-19 18:39 ` Mario Limonciello
2009-08-19 18:36 Mario Limonciello
2009-08-19 18:42 ` Johannes Berg
2009-08-19 18:47 ` Mario Limonciello
2009-08-20 8:52 ` Alan Jenkins
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=4A8C2C6C.2020007@dell.com \
--to=mario_limonciello@dell.com \
--cc=cezary.jackiewicz@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=sourcejedi.lkml@googlemail.com \
/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;
as well as URLs for NNTP newsgroup(s).