aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-06-16 09:54:04 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-19 11:50:18 -0400
commit464902e812025792c9e33e19e1555c343672d5cf (patch)
treecc243de464a7935291c52ac93d6bd0a24c6c08c5
parent96e9cfeb9692b0bc6e03f9b6f9cb3c67a40b76d1 (diff)
rfkill: export persistent attribute in sysfs
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>
-rw-r--r--Documentation/rfkill.txt2
-rw-r--r--include/linux/rfkill.h5
-rw-r--r--net/rfkill/core.c10
3 files changed, 15 insertions, 2 deletions
diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
index c8acd8659e91..b4860509c319 100644
--- a/Documentation/rfkill.txt
+++ b/Documentation/rfkill.txt
@@ -111,6 +111,8 @@ following attributes:
111 111
112 name: Name assigned by driver to this key (interface or driver name). 112 name: Name assigned by driver to this key (interface or driver name).
113 type: Driver type string ("wlan", "bluetooth", etc). 113 type: Driver type string ("wlan", "bluetooth", etc).
114 persistent: Whether the soft blocked state is initialised from
115 non-volatile storage at startup.
114 state: Current state of the transmitter 116 state: Current state of the transmitter
115 0: RFKILL_STATE_SOFT_BLOCKED 117 0: RFKILL_STATE_SOFT_BLOCKED
116 transmitter is turned off by software 118 transmitter is turned off by software
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index dcac724340d8..e73e2429a1b1 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -259,8 +259,9 @@ bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
259 * userspace) of their initial state. It should only be used before 259 * userspace) of their initial state. It should only be used before
260 * registration. 260 * registration.
261 * 261 *
262 * In addition, it marks the device as "persistent". Persistent devices 262 * In addition, it marks the device as "persistent", an attribute which
263 * are expected to preserve preserve their own state when suspended. 263 * can be read by userspace. Persistent devices are expected to preserve
264 * their own state when suspended.
264 */ 265 */
265void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked); 266void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
266 267
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index dcf8df7c573c..79693fe2001e 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -610,6 +610,15 @@ static ssize_t rfkill_idx_show(struct device *dev,
610 return sprintf(buf, "%d\n", rfkill->idx); 610 return sprintf(buf, "%d\n", rfkill->idx);
611} 611}
612 612
613static ssize_t rfkill_persistent_show(struct device *dev,
614 struct device_attribute *attr,
615 char *buf)
616{
617 struct rfkill *rfkill = to_rfkill(dev);
618
619 return sprintf(buf, "%d\n", rfkill->persistent);
620}
621
613static u8 user_state_from_blocked(unsigned long state) 622static u8 user_state_from_blocked(unsigned long state)
614{ 623{
615 if (state & RFKILL_BLOCK_HW) 624 if (state & RFKILL_BLOCK_HW)
@@ -668,6 +677,7 @@ static struct device_attribute rfkill_dev_attrs[] = {
668 __ATTR(name, S_IRUGO, rfkill_name_show, NULL), 677 __ATTR(name, S_IRUGO, rfkill_name_show, NULL),
669 __ATTR(type, S_IRUGO, rfkill_type_show, NULL), 678 __ATTR(type, S_IRUGO, rfkill_type_show, NULL),
670 __ATTR(index, S_IRUGO, rfkill_idx_show, NULL), 679 __ATTR(index, S_IRUGO, rfkill_idx_show, NULL),
680 __ATTR(persistent, S_IRUGO, rfkill_persistent_show, NULL),
671 __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store), 681 __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store),
672 __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store), 682 __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store),
673 __ATTR_NULL 683 __ATTR_NULL