From patchwork Wed Apr 8 13:27:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Jenkins X-Patchwork-Id: 17175 X-Patchwork-Delegate: corentincj@iksaif.net Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n38DRj6K019013 for ; Wed, 8 Apr 2009 13:27:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754357AbZDHN1a (ORCPT ); Wed, 8 Apr 2009 09:27:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758598AbZDHN13 (ORCPT ); Wed, 8 Apr 2009 09:27:29 -0400 Received: from fg-out-1718.google.com ([72.14.220.156]:36891 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754357AbZDHN12 (ORCPT ); Wed, 8 Apr 2009 09:27:28 -0400 Received: by fg-out-1718.google.com with SMTP id e12so41944fga.17 for ; Wed, 08 Apr 2009 06:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=F/Pz9g7EAA48jszI4cz1Yk/j0ndzJvz4qB6q1u+f5oA=; b=xTBd/GC2IIpokom/GOQ76ty5KdcT6ECQ++8LA1Keq2nI6pvAZcm0FJM10muB4uEfr4 fT+iaBpCBCNVgMcNeH6VeU8+aomdxJ9igymG3WR5xNB9ibabPZnb3NBB8oR7y09XE+zh 3rbeoTZKYdxhakjBWt2zwL0GB/OSht8klP7dM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=cf7Rx2p7OuZIWje3iiXzq54e7HoQLM4QixLAZJOoijcitDp2giwL8vL+5tEhn7uuM8 gjczh3CYHodPtULaDA501voeuwN1PFO5JC2aUvrUS5l63DxlCNphN3Lwkic4K7PW9atD xcy/I3bYaaXZ6h6zAek9sb28d5oH1t574bNHY= Received: by 10.86.65.9 with SMTP id n9mr1057702fga.55.1239197246288; Wed, 08 Apr 2009 06:27:26 -0700 (PDT) Received: from ?192.168.0.5? ([86.53.68.233]) by mx.google.com with ESMTPS id l12sm10182684fgb.6.2009.04.08.06.27.24 (version=SSLv3 cipher=RC4-MD5); Wed, 08 Apr 2009 06:27:25 -0700 (PDT) Message-ID: <49DCA63B.5050802@tuffmail.co.uk> Date: Wed, 08 Apr 2009 14:27:23 +0100 From: Alan Jenkins User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Corentin Chary CC: linux acpi , Matthew Garrett Subject: [PATCH] eeepc-laptop: Work around rfkill firmware bug Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 1) Buggy firmware can change the RFKILL state by itself. This is easily detected. The RFKILL API states that in such cases, we should call rfkill_force_state() to notify the core. I have reported the bug to Asus. I believe this is the right thing to do for robustness, even if this particular firmware bug is fixed. 2) The same bug causes the wireless toggle key to be reported as 0x11 instead of 0x10. 0x11 is otherwise unused, so it should be safe to add this as a new keycode. The bug is triggered by removing the laptop battery while hibernated. On resume, the wireless toggle key causes the firmware to toggle the wireless state itself. (Also, the key is reported as 0x11 when the current wireless state is OFF). This is very poor behaviour because the OS can't predict whether the firmware is controlling the RFKILL state. Without this workaround, the bug means users have to press the wireless toggle key twice to enable, due to the OS/firmware conflict. (Assuming rfkill-input or equivalent is being used). The workaround avoids this. I believe that acpid scripts which toggle the value of the sysfs state file when the toggle key is pressed will be rendered ineffective by the bug, regardless of this workaround. If they simply toggle the state, when the firmware has already toggled it, then you will never see a state change. Tested on "EEEPC 4G" only. Signed-off-by: Alan Jenkins --- drivers/platform/x86/eeepc-laptop.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index e21f7cd..f725eaf 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c @@ -158,6 +158,7 @@ enum { KE_KEY, KE_END }; static struct key_entry eeepc_keymap[] = { /* Sleep already handled via generic ACPI code */ {KE_KEY, 0x10, KEY_WLAN }, + {KE_KEY, 0x11, KEY_WLAN }, {KE_KEY, 0x12, KEY_PROG1 }, {KE_KEY, 0x13, KEY_MUTE }, {KE_KEY, 0x14, KEY_VOLUMEDOWN }, @@ -521,6 +522,7 @@ static void notify_brn(void) static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) { + enum rfkill_state state; struct pci_dev *dev; struct pci_bus *bus = pci_find_bus(0, 1); @@ -532,7 +534,9 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) return; } - if (get_acpi(CM_ASL_WLAN) == 1) { + eeepc_wlan_rfkill_state(ehotk->eeepc_wlan_rfkill, &state); + + if (state == RFKILL_STATE_UNBLOCKED) { dev = pci_get_slot(bus, 0); if (dev) { /* Device already present */ @@ -552,6 +556,8 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) pci_dev_put(dev); } } + + rfkill_force_state(ehotk->eeepc_wlan_rfkill, state); } static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)