rfkill: export persistent attribute in sysfs
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>
Tue, 16 Jun 2009 13:54:04 +0000 (14:54 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 19 Jun 2009 15:50:18 +0000 (11:50 -0400)
This information allows userspace to implement a hybrid policy where
it can store the rfkill soft-blocked state in platform non-volatile
storage if available, and if not then file-based storage can be used.

Some users prefer platform non-volatile storage because of the behaviour
when dual-booting multiple versions of Linux, or if the rfkill setting
is changed in the BIOS setting screens, or if the BIOS responds to
wireless-toggle hotkeys itself before the relevant platform driver has
been loaded.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Documentation/rfkill.txt
include/linux/rfkill.h
net/rfkill/core.c

index c8acd8659e91cb0a454e4c7e19501e24fe00a5b9..b4860509c319676b87f4a898f88eab15fe2cb08b 100644 (file)
@@ -111,6 +111,8 @@ following attributes:
 
        name: Name assigned by driver to this key (interface or driver name).
        type: Driver type string ("wlan", "bluetooth", etc).
+       persistent: Whether the soft blocked state is initialised from
+                   non-volatile storage at startup.
        state: Current state of the transmitter
                0: RFKILL_STATE_SOFT_BLOCKED
                        transmitter is turned off by software
index dcac724340d8303d7bc64e6290659f1f0b974948..e73e2429a1b1cab128e1561865b3f12ca822a8e8 100644 (file)
@@ -259,8 +259,9 @@ bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
  * userspace) of their initial state.  It should only be used before
  * registration.
  *
- * In addition, it marks the device as "persistent".  Persistent devices
- * are expected to preserve preserve their own state when suspended.
+ * In addition, it marks the device as "persistent", an attribute which
+ * can be read by userspace.  Persistent devices are expected to preserve
+ * their own state when suspended.
  */
 void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
 
index dcf8df7c573cccc06dd7389276aae99c41696cd7..79693fe2001e50df79d259a41dec1f6aa28b9370 100644 (file)
@@ -610,6 +610,15 @@ static ssize_t rfkill_idx_show(struct device *dev,
        return sprintf(buf, "%d\n", rfkill->idx);
 }
 
+static ssize_t rfkill_persistent_show(struct device *dev,
+                              struct device_attribute *attr,
+                              char *buf)
+{
+       struct rfkill *rfkill = to_rfkill(dev);
+
+       return sprintf(buf, "%d\n", rfkill->persistent);
+}
+
 static u8 user_state_from_blocked(unsigned long state)
 {
        if (state & RFKILL_BLOCK_HW)
@@ -668,6 +677,7 @@ static struct device_attribute rfkill_dev_attrs[] = {
        __ATTR(name, S_IRUGO, rfkill_name_show, NULL),
        __ATTR(type, S_IRUGO, rfkill_type_show, NULL),
        __ATTR(index, S_IRUGO, rfkill_idx_show, NULL),
+       __ATTR(persistent, S_IRUGO, rfkill_persistent_show, NULL),
        __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store),
        __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store),
        __ATTR_NULL