All of lore.kernel.org
 help / color / mirror / Atom feed
From: "João Paulo Rechi Vita" <jprvita@gmail.com>
To: Corentin Chary <corentin.chary@gmail.com>
Cc: platform-driver-x86@vger.kernel.org,
	acpi4asus-user@lists.sourceforge.net, jprvita@gmail.com,
	"João Paulo Rechi Vita" <jprvita@endlessm.com>
Subject: [PATCH 3/4] net/rfkill: Create "airplane mode" LED trigger
Date: Tue, 15 Dec 2015 10:30:41 -0500	[thread overview]
Message-ID: <1450193442-7930-4-git-send-email-jprvita@endlessm.com> (raw)
In-Reply-To: <1450193442-7930-1-git-send-email-jprvita@endlessm.com>

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-wrc x86 platform driver.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
---
 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;
 }
-- 
2.5.0

  parent reply	other threads:[~2015-12-15 15:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15 15:30 [RFC 0/4] Asus Wireless Radio Control driver João Paulo Rechi Vita
2015-12-15 15:30 ` [PATCH 1/4] platform/x86: Add " João Paulo Rechi Vita
2015-12-19  6:39   ` Darren Hart
     [not found]     ` <CA+A7VXWGTAsen2V29ifJ9nGCuHRnQnZi=Q_oEi1fkmeo=t1gxQ@mail.gmail.com>
2015-12-20 16:58       ` João Paulo Rechi Vita
2015-12-19  7:23   ` Darren Hart
     [not found]     ` <CA+A7VXU9MepWmWL6BS+XyjbLs2s_ONR5Yy3tqT--cbYS7p1P1Q@mail.gmail.com>
2015-12-20 17:00       ` João Paulo Rechi Vita
2015-12-15 15:30 ` [PATCH 2/4] asus-wrc: Add ACPI HID ATK4001 João Paulo Rechi Vita
2015-12-19  6:40   ` Darren Hart
2015-12-20 18:57     ` João Paulo Rechi Vita
2015-12-15 15:30 ` João Paulo Rechi Vita [this message]
2015-12-19  0:22   ` [PATCH 3/4] net/rfkill: Create "airplane mode" LED trigger Darren Hart
2015-12-19  0:36     ` João Paulo Rechi Vita
2015-12-19  2:25     ` David Miller
2015-12-15 15:30 ` [PATCH 4/4] asus-wrc: Toggle airplane mode LED João Paulo Rechi Vita
2015-12-19  8:00 ` [RFC 0/4] Asus Wireless Radio Control driver Darren Hart
2015-12-20 19:01   ` João Paulo Rechi Vita
2015-12-26 14:56 [RFCv2 " João Paulo Rechi Vita
2015-12-26 14:56 ` [PATCH 3/4] net/rfkill: Create "airplane mode" LED trigger João Paulo Rechi Vita

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=1450193442-7930-4-git-send-email-jprvita@endlessm.com \
    --to=jprvita@gmail.com \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=corentin.chary@gmail.com \
    --cc=jprvita@endlessm.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.