Commit 464902e812025792c9e33e19e1555c343672d5cf
Committed by
John W. Linville
1 parent
96e9cfeb96
Exists in
master
and in
7 other branches
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>
Showing 3 changed files with 15 additions and 2 deletions Side-by-side Diff
Documentation/rfkill.txt
| ... | ... | @@ -111,6 +111,8 @@ |
| 111 | 111 | |
| 112 | 112 | name: Name assigned by driver to this key (interface or driver name). |
| 113 | 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 | 116 | state: Current state of the transmitter |
| 115 | 117 | 0: RFKILL_STATE_SOFT_BLOCKED |
| 116 | 118 | transmitter is turned off by software |
include/linux/rfkill.h
| ... | ... | @@ -259,8 +259,9 @@ |
| 259 | 259 | * userspace) of their initial state. It should only be used before |
| 260 | 260 | * registration. |
| 261 | 261 | * |
| 262 | - * In addition, it marks the device as "persistent". Persistent devices | |
| 263 | - * are expected to preserve preserve their own state when suspended. | |
| 262 | + * In addition, it marks the device as "persistent", an attribute which | |
| 263 | + * can be read by userspace. Persistent devices are expected to preserve | |
| 264 | + * their own state when suspended. | |
| 264 | 265 | */ |
| 265 | 266 | void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked); |
| 266 | 267 |
net/rfkill/core.c
| ... | ... | @@ -610,6 +610,15 @@ |
| 610 | 610 | return sprintf(buf, "%d\n", rfkill->idx); |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | +static 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 | + | |
| 613 | 622 | static u8 user_state_from_blocked(unsigned long state) |
| 614 | 623 | { |
| 615 | 624 | if (state & RFKILL_BLOCK_HW) |
| ... | ... | @@ -668,6 +677,7 @@ |
| 668 | 677 | __ATTR(name, S_IRUGO, rfkill_name_show, NULL), |
| 669 | 678 | __ATTR(type, S_IRUGO, rfkill_type_show, NULL), |
| 670 | 679 | __ATTR(index, S_IRUGO, rfkill_idx_show, NULL), |
| 680 | + __ATTR(persistent, S_IRUGO, rfkill_persistent_show, NULL), | |
| 671 | 681 | __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store), |
| 672 | 682 | __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store), |
| 673 | 683 | __ATTR_NULL |