[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1456159001-20307-11-git-send-email-jprvita@endlessm.com>
Date: Mon, 22 Feb 2016 11:36:41 -0500
From: "João Paulo Rechi Vita" <jprvita@...il.com>
To: Johannes Berg <johannes@...solutions.net>
Cc: "David S. Miller" <davem@...emloft.net>,
Darren Hart <dvhart@...radead.org>,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
platform-driver-x86@...r.kernel.org, linux-api@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux@...lessm.com,
João Paulo Rechi Vita <jprvita@...lessm.com>
Subject: [PATCHv2 10/10] rfkill: Notify userspace of airplane-mode state changes
Signed-off-by: João Paulo Rechi Vita <jprvita@...lessm.com>
---
Documentation/rfkill.txt | 3 +++
include/uapi/linux/rfkill.h | 4 ++--
net/rfkill/core.c | 13 +++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
index 9dbe3fc..588b4bf 100644
--- a/Documentation/rfkill.txt
+++ b/Documentation/rfkill.txt
@@ -133,5 +133,8 @@ applications to take control. Changes to the airplane-mode indicator state can
be made using RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE, passing the new value
in the 'soft' field of 'struct rfkill_event'.
+This same API is also used to provide userspace with notifications of changes
+to airplane-mode indicator state.
+
For further details consult Documentation/ABI/stable/sysfs-class-rfkill.
diff --git a/include/uapi/linux/rfkill.h b/include/uapi/linux/rfkill.h
index 36e0770..2ccb02f 100644
--- a/include/uapi/linux/rfkill.h
+++ b/include/uapi/linux/rfkill.h
@@ -63,8 +63,8 @@ enum rfkill_type {
* are hot-plugged later.
* @RFKILL_OP_AIRPLANE_MODE_INDICATOR_ACQUIRE: userspace acquires control of
* the airplane-mode indicator.
- * @RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE: userspace changes the
- * airplane-mode indicator state.
+ * @RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE: the airplane-mode indicator state
+ * changed -- userspace changes the airplane-mode indicator state.
*/
enum rfkill_operation {
RFKILL_OP_ADD = 0,
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 8ea8b73..c59fd1d 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -131,7 +131,20 @@ static struct led_trigger rfkill_apm_led_trigger;
static void rfkill_apm_led_trigger_event(bool state)
{
+ struct rfkill_data *data;
+ struct rfkill_int_event *ev;
+
led_trigger_event(&rfkill_apm_led_trigger, state ? LED_FULL : LED_OFF);
+
+ list_for_each_entry(data, &rfkill_fds, list) {
+ ev = kzalloc(sizeof(*ev), GFP_KERNEL);
+ if (!ev)
+ continue;
+ ev->ev.op = RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE;
+ ev->ev.soft = state;
+ list_add_tail(&ev->list, &data->events);
+ wake_up_interruptible(&data->read_wait);
+ }
}
static void rfkill_apm_led_trigger_activate(struct led_classdev *led)
--
2.5.0
Powered by blists - more mailing lists