From patchwork Sat Dec 26 15:05:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Paulo_Rechi_Vita?= X-Patchwork-Id: 7921891 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 28B5CBEEE5 for ; Sat, 26 Dec 2015 15:06:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D04F20374 for ; Sat, 26 Dec 2015 15:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A89B20379 for ; Sat, 26 Dec 2015 15:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752022AbbLZPFf (ORCPT ); Sat, 26 Dec 2015 10:05:35 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:32809 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751998AbbLZPFQ (ORCPT ); Sat, 26 Dec 2015 10:05:16 -0500 Received: by mail-pf0-f182.google.com with SMTP id q63so55624163pfb.0; Sat, 26 Dec 2015 07:05:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=PyfVKKkP5c4+oVEOgLO/1xoDPBrDnWJHQ24li/lbnVc=; b=C3pyT88j215bDxFIyrq328/PMQ2jXIp+P5WM2hfaaswqlvmIJ0OpkaWdL1NGCYuaq9 NgrzdCtvXzoA7Ua9pNyy8mce8JTNCd/jsD4/tezyrR91y22YVNFv1TBiiRYgLFs83x8O ZitiqXK3Fbc85gj8M8BDzD6igsGxJJmhftUTDtuxWmdf7EiGVuzRzEyicfTbx9dCzoge YCn1wFXz3HYOtrC7yT7f/EkGkfsEU7eJtslzH+wursPgb9cZzj7RaJPk1ptCxOOUytfz IgfEyNbAqLJuXpT9/+Wk6IiWb0ExJ1jH0Dwgc+pbHYhGbhzur26dx+j85HbgOYD21850 H58w== X-Received: by 10.98.74.220 with SMTP id c89mr65621199pfj.11.1451142315608; Sat, 26 Dec 2015 07:05:15 -0800 (PST) Received: from localhost.localdomain ([128.177.161.180]) by smtp.gmail.com with ESMTPSA id m75sm40536452pfi.0.2015.12.26.07.05.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Dec 2015 07:05:15 -0800 (PST) From: "=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=" X-Google-Original-From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= To: Johannes Berg Cc: "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Subject: [PATCH] net/rfkill: Create "airplane mode" LED trigger Date: Sat, 26 Dec 2015 10:05:03 -0500 Message-Id: <1451142303-1872-2-git-send-email-jprvita@endlessm.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1451142303-1872-1-git-send-email-jprvita@endlessm.com> References: <1451142303-1872-1-git-send-email-jprvita@endlessm.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For platform drivers to be able to correctly drive the "Airplane Mode" indicative LED there needs to be a RFKill LED trigger tied to the global state of RFKILL_TYPE_ALL (instead of to a specific RFKill) and that works in an inverted manner of regular RFKill LED triggers, that is, the LED is ON when the state is blocked, and OFF otherwise. This commit implements such a trigger, which will be used by the asus-wireless x86 platform driver. Signed-off-by: João Paulo Rechi Vita --- net/rfkill/core.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/net/rfkill/core.c b/net/rfkill/core.c index b41e9ea..3effc29 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -124,6 +124,26 @@ static bool rfkill_epo_lock_active; #ifdef CONFIG_RFKILL_LEDS +static void airplane_mode_led_trigger_activate(struct led_classdev *led); + +static struct led_trigger airplane_mode_led_trigger = { + .name = "rfkill-airplane-mode", + .activate = airplane_mode_led_trigger_activate, +}; + +static void airplane_mode_led_trigger_event(void) +{ + if (rfkill_global_states[RFKILL_TYPE_ALL].cur & RFKILL_BLOCK_ANY) + led_trigger_event(&airplane_mode_led_trigger, LED_FULL); + else + led_trigger_event(&airplane_mode_led_trigger, LED_OFF); +} + +static void airplane_mode_led_trigger_activate(struct led_classdev *led) +{ + airplane_mode_led_trigger_event(); +} + static void rfkill_led_trigger_event(struct rfkill *rfkill) { struct led_trigger *trigger; @@ -175,6 +195,10 @@ static void rfkill_led_trigger_unregister(struct rfkill *rfkill) led_trigger_unregister(&rfkill->led_trigger); } #else +static void airplane_mode_led_trigger_event(void) +{ +} + static void rfkill_led_trigger_event(struct rfkill *rfkill) { } @@ -346,6 +370,7 @@ static void __rfkill_switch_all(const enum rfkill_type type, bool blocked) for (i = 0; i < NUM_RFKILL_TYPES; i++) rfkill_global_states[i].cur = blocked; + airplane_mode_led_trigger_event(); } else { rfkill_global_states[type].cur = blocked; } @@ -1177,6 +1202,7 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf, enum rfkill_type i; for (i = 0; i < NUM_RFKILL_TYPES; i++) rfkill_global_states[i].cur = ev.soft; + airplane_mode_led_trigger_event(); } else { rfkill_global_states[ev.type].cur = ev.soft; } @@ -1293,6 +1319,10 @@ static int __init rfkill_init(void) } #endif +#ifdef CONFIG_RFKILL_LEDS + led_trigger_register(&airplane_mode_led_trigger); +#endif + out: return error; }