Skip to contentSkip to conversation

rfkill: export persistent attribute in sysfs

PATCH In review Alan Jenkins 3 participants 4 messages Jun 16, 2009 – Jun 18, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 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.

---
 Documentation/rfkill.txt |    2 ++
 include/linux/rfkill.h   |    5 +++--
 net/rfkill/core.c        |   10 ++++++++++
 3 files changed, 15 insertions(+), 2 deletions(-)
Documentation/rfkill.txt +2 -0
index c8acd86..b486050 100644
@@ -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
include/linux/rfkill.h +3 -2
index 84b6b9c..0592552 100644
@@ -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
+ * preserve their own state when suspended.
  */
 void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
 
net/rfkill/core.c +10 -0
index dcf8df7..79693fe 100644
@@ -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
Acked-by on v1 4/4
#1 lore raw

Hi Alan,

Quoted 11 lines

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.

as I mentioned before, I agree with doing it this way.

Regards

Marcel

Acked-by on v1 4/4
#2 lore raw
In reply to Alan Jenkins
Quoted 2 lines · Alan Jenkins

+ * can be read by userspace. Persistent devices are expected to preserve
+ * preserve their own state when suspended.

You have "preserve" twice in there.

Other than that,

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#3 lore raw
Quoted 6 lines · Henrique de Moraes Holschuh
Quoted 3 lines · Alan Jenkins

+ * can be read by userspace. Persistent devices are expected to preserve
+ * preserve their own state when suspended.

Quoted 6 lines

You have "preserve" twice in there.

Other than that,

I see the patches are already in wireless-testing and -next. I'll send an incremental patch to fix this one comment.