From c5891a4b0971c4592ec024b30c04de9cfe88f8b0 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sun, 11 Oct 2009 10:32:56 -0500 Subject: [PATCH] UBUNTU: SAUCE: dell-laptop: Store the HW switch status internally rather than requerying every time If we are called from dell_rfkill_update, we can't rely on the output from dell_send_request to infer the status of WLAN/BT/WWAN because sometimes the BIOS sends the scancode before changing the status. The RFKILL subsystem doesn't have a good way to "query" specifically the HW blocked bits, so we need to store it internally instead. We also shouldn't be querying the BIOS for the status of the softblock status because that's supposed to be done at a higher level and if this is queried when the hardware killswitch is in the off/disabled position, this causes the system to be stuck in a softblock state. This patch applies on-top of Matthew Garret's two unaccepted patches that hook into the input subsystem. OriginalAuthor: Mario Limonciello BugLink: http://bugs.launchpad.net/bugs/430809 Ignore: no Signed-off-by: Mario Limonciello --- drivers/platform/x86/dell-laptop.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index b6080cc..b567851 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -64,6 +64,8 @@ static struct rfkill *wifi_rfkill; static struct rfkill *bluetooth_rfkill; static struct rfkill *wwan_rfkill; +static bool hw_switch_status; + static const struct dmi_system_id __initdata dell_device_table[] = { { .ident = "Dell laptop", @@ -202,8 +204,8 @@ static void dell_rfkill_query(struct rfkill *rfkill, void *data) dell_send_request(&buffer, 17, 11); status = buffer.output[1]; - rfkill_set_sw_state(rfkill, !!(status & BIT(bit))); - rfkill_set_hw_state(rfkill, !(status & BIT(16))); + hw_switch_status = !(status & BIT(16)); + rfkill_set_hw_state(rfkill, hw_switch_status); } static const struct rfkill_ops dell_rfkill_ops = { @@ -214,11 +216,12 @@ static const struct rfkill_ops dell_rfkill_ops = { static void dell_rfkill_update(void) { if (wifi_rfkill) - dell_rfkill_query(wifi_rfkill, (void *)1); + rfkill_set_hw_state(wifi_rfkill, !hw_switch_status); if (bluetooth_rfkill) - dell_rfkill_query(bluetooth_rfkill, (void *)2); + rfkill_set_hw_state(bluetooth_rfkill, !hw_switch_status); if (wwan_rfkill) - dell_rfkill_query(wwan_rfkill, (void *)3); + rfkill_set_hw_state(wwan_rfkill, !hw_switch_status); + hw_switch_status = !hw_switch_status; } static int dell_setup_rfkill(void) -- 1.6.3.3