From: Daniel Drake Date: Wed, 18 Apr 2012 17:08:21 +0000 (+0100) Subject: xo1-rfkill: only act when blocked state is changed X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=bc7ab495c7532f06bc03021c0d78ac384fb13c14;p=linux-beck.git xo1-rfkill: only act when blocked state is changed The XO-1 rfkill driver should only send EC commands when changing between blocked/unblocked state. The rfkill switch is asked to be unblocked on every resume (even when the card was never blocked before) and sending a EC_WLAN_LEAVE_RESET command here upsets the resume sequence of the libertas driver. Adding the check to avoid the spurious EC_WLAN_LEAVE_RESET fixes the wifi resume behaviour. The rfkill state is maintained by the hardware over suspend/resume so no extra consideration is needed here. Signed-off-by: Daniel Drake Signed-off-by: Matthew Garrett --- diff --git a/drivers/platform/x86/xo1-rfkill.c b/drivers/platform/x86/xo1-rfkill.c index 41781ed8301c..b57ad8641480 100644 --- a/drivers/platform/x86/xo1-rfkill.c +++ b/drivers/platform/x86/xo1-rfkill.c @@ -15,15 +15,26 @@ #include +static bool card_blocked; + static int rfkill_set_block(void *data, bool blocked) { unsigned char cmd; + int r; + + if (blocked == card_blocked) + return 0; + if (blocked) cmd = EC_WLAN_ENTER_RESET; else cmd = EC_WLAN_LEAVE_RESET; - return olpc_ec_cmd(cmd, NULL, 0, NULL, 0); + r = olpc_ec_cmd(cmd, NULL, 0, NULL, 0); + if (r == 0) + card_blocked = blocked; + + return r; } static const struct rfkill_ops rfkill_ops = {