Commit 621cac85297de5ba655e3430b007dd2e0da91da6
Committed by
John W. Linville
1 parent
c1c6b14b22
Exists in
master
and in
4 other branches
rfkill: remove user_claim stuff
Almost all drivers do not support user_claim, so remove it completely and always report -EOPNOTSUPP to userspace. Since userspace cannot really drive rfkill _anyway_ (due to the odd restrictions imposed by the documentation) having this code is just pointless. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Showing 12 changed files with 9 additions and 72 deletions Side-by-side Diff
- Documentation/rfkill.txt
- drivers/net/wireless/ath9k/main.c
- drivers/net/wireless/b43/rfkill.c
- drivers/net/wireless/b43legacy/rfkill.c
- drivers/net/wireless/iwlwifi/iwl-rfkill.c
- drivers/platform/x86/acer-wmi.c
- drivers/platform/x86/hp-wmi.c
- drivers/platform/x86/sony-laptop.c
- drivers/platform/x86/toshiba_acpi.c
- include/linux/rfkill.h
- net/rfkill/rfkill.c
- net/wimax/op-rfkill.c
Documentation/rfkill.txt
... | ... | @@ -521,16 +521,12 @@ |
521 | 521 | Input devices may issue events that are related to rfkill. These are the |
522 | 522 | various KEY_* events and SW_* events supported by rfkill-input.c. |
523 | 523 | |
524 | -******IMPORTANT****** | |
525 | -When rfkill-input is ACTIVE, userspace is NOT TO CHANGE THE STATE OF AN RFKILL | |
526 | -SWITCH IN RESPONSE TO AN INPUT EVENT also handled by rfkill-input, unless it | |
527 | -has set to true the user_claim attribute for that particular switch. This rule | |
528 | -is *absolute*; do NOT violate it. | |
529 | -******IMPORTANT****** | |
524 | +Userspace may not change the state of an rfkill switch in response to an | |
525 | +input event, it should refrain from changing states entirely. | |
530 | 526 | |
531 | -Userspace must not assume it is the only source of control for rfkill switches. | |
532 | -Their state CAN and WILL change due to firmware actions, direct user actions, | |
533 | -and the rfkill-input EPO override for *_RFKILL_ALL. | |
527 | +Userspace cannot assume it is the only source of control for rfkill switches. | |
528 | +Their state can change due to firmware actions, direct user actions, and the | |
529 | +rfkill-input EPO override for *_RFKILL_ALL. | |
534 | 530 | |
535 | 531 | When rfkill-input is not active, userspace must initiate a rfkill status |
536 | 532 | change by writing to the "state" attribute in order for anything to happen. |
drivers/net/wireless/ath9k/main.c
drivers/net/wireless/b43/rfkill.c
... | ... | @@ -139,7 +139,6 @@ |
139 | 139 | rfk->rfkill->state = RFKILL_STATE_UNBLOCKED; |
140 | 140 | rfk->rfkill->data = dev; |
141 | 141 | rfk->rfkill->toggle_radio = b43_rfkill_soft_toggle; |
142 | - rfk->rfkill->user_claim_unsupported = 1; | |
143 | 142 | |
144 | 143 | rfk->poll_dev = input_allocate_polled_device(); |
145 | 144 | if (!rfk->poll_dev) { |
drivers/net/wireless/b43legacy/rfkill.c
... | ... | @@ -142,7 +142,6 @@ |
142 | 142 | rfk->rfkill->state = RFKILL_STATE_UNBLOCKED; |
143 | 143 | rfk->rfkill->data = dev; |
144 | 144 | rfk->rfkill->toggle_radio = b43legacy_rfkill_soft_toggle; |
145 | - rfk->rfkill->user_claim_unsupported = 1; | |
146 | 145 | |
147 | 146 | rfk->poll_dev = input_allocate_polled_device(); |
148 | 147 | if (!rfk->poll_dev) { |
drivers/net/wireless/iwlwifi/iwl-rfkill.c
... | ... | @@ -91,7 +91,6 @@ |
91 | 91 | priv->rfkill->data = priv; |
92 | 92 | priv->rfkill->state = RFKILL_STATE_UNBLOCKED; |
93 | 93 | priv->rfkill->toggle_radio = iwl_rfkill_soft_rf_kill; |
94 | - priv->rfkill->user_claim_unsupported = 1; | |
95 | 94 | |
96 | 95 | priv->rfkill->dev.class->suspend = NULL; |
97 | 96 | priv->rfkill->dev.class->resume = NULL; |
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/hp-wmi.c
... | ... | @@ -434,7 +434,6 @@ |
434 | 434 | wifi_rfkill->name = "hp-wifi"; |
435 | 435 | wifi_rfkill->state = hp_wmi_wifi_state(); |
436 | 436 | wifi_rfkill->toggle_radio = hp_wmi_wifi_set; |
437 | - wifi_rfkill->user_claim_unsupported = 1; | |
438 | 437 | err = rfkill_register(wifi_rfkill); |
439 | 438 | if (err) |
440 | 439 | goto add_sysfs_error; |
... | ... | @@ -446,7 +445,6 @@ |
446 | 445 | bluetooth_rfkill->name = "hp-bluetooth"; |
447 | 446 | bluetooth_rfkill->state = hp_wmi_bluetooth_state(); |
448 | 447 | bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; |
449 | - bluetooth_rfkill->user_claim_unsupported = 1; | |
450 | 448 | err = rfkill_register(bluetooth_rfkill); |
451 | 449 | if (err) |
452 | 450 | goto register_bluetooth_error; |
... | ... | @@ -457,7 +455,6 @@ |
457 | 455 | wwan_rfkill->name = "hp-wwan"; |
458 | 456 | wwan_rfkill->state = hp_wmi_wwan_state(); |
459 | 457 | wwan_rfkill->toggle_radio = hp_wmi_wwan_set; |
460 | - wwan_rfkill->user_claim_unsupported = 1; | |
461 | 458 | err = rfkill_register(wwan_rfkill); |
462 | 459 | if (err) |
463 | 460 | goto register_wwan_err; |
drivers/platform/x86/sony-laptop.c
... | ... | @@ -1097,7 +1097,6 @@ |
1097 | 1097 | sony_wifi_rfkill->name = "sony-wifi"; |
1098 | 1098 | sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set; |
1099 | 1099 | sony_wifi_rfkill->get_state = sony_nc_rfkill_get; |
1100 | - sony_wifi_rfkill->user_claim_unsupported = 1; | |
1101 | 1100 | sony_wifi_rfkill->data = (void *)SONY_WIFI; |
1102 | 1101 | err = rfkill_register(sony_wifi_rfkill); |
1103 | 1102 | if (err) |
... | ... | @@ -1119,7 +1118,6 @@ |
1119 | 1118 | sony_bluetooth_rfkill->name = "sony-bluetooth"; |
1120 | 1119 | sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set; |
1121 | 1120 | sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get; |
1122 | - sony_bluetooth_rfkill->user_claim_unsupported = 1; | |
1123 | 1121 | sony_bluetooth_rfkill->data = (void *)SONY_BLUETOOTH; |
1124 | 1122 | err = rfkill_register(sony_bluetooth_rfkill); |
1125 | 1123 | if (err) |
... | ... | @@ -1140,7 +1138,6 @@ |
1140 | 1138 | sony_wwan_rfkill->name = "sony-wwan"; |
1141 | 1139 | sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set; |
1142 | 1140 | sony_wwan_rfkill->get_state = sony_nc_rfkill_get; |
1143 | - sony_wwan_rfkill->user_claim_unsupported = 1; | |
1144 | 1141 | sony_wwan_rfkill->data = (void *)SONY_WWAN; |
1145 | 1142 | err = rfkill_register(sony_wwan_rfkill); |
1146 | 1143 | if (err) |
... | ... | @@ -1161,7 +1158,6 @@ |
1161 | 1158 | sony_wimax_rfkill->name = "sony-wimax"; |
1162 | 1159 | sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set; |
1163 | 1160 | sony_wimax_rfkill->get_state = sony_nc_rfkill_get; |
1164 | - sony_wimax_rfkill->user_claim_unsupported = 1; | |
1165 | 1161 | sony_wimax_rfkill->data = (void *)SONY_WIMAX; |
1166 | 1162 | err = rfkill_register(sony_wimax_rfkill); |
1167 | 1163 | if (err) |
drivers/platform/x86/toshiba_acpi.c
... | ... | @@ -803,7 +803,6 @@ |
803 | 803 | |
804 | 804 | toshiba_acpi.rfk_dev->name = toshiba_acpi.bt_name; |
805 | 805 | toshiba_acpi.rfk_dev->toggle_radio = bt_rfkill_toggle_radio; |
806 | - toshiba_acpi.rfk_dev->user_claim_unsupported = 1; | |
807 | 806 | toshiba_acpi.rfk_dev->data = &toshiba_acpi; |
808 | 807 | |
809 | 808 | if (hci_get_bt_on(&bt_on) == HCI_SUCCESS && bt_on) { |
include/linux/rfkill.h
... | ... | @@ -58,9 +58,6 @@ |
58 | 58 | * @type: Radio type which the button controls, the value stored |
59 | 59 | * here should be a value from enum rfkill_type. |
60 | 60 | * @state: State of the switch, "UNBLOCKED" means radio can operate. |
61 | - * @user_claim_unsupported: Whether the hardware supports exclusive | |
62 | - * RF-kill control by userspace. Set this before registering. | |
63 | - * @user_claim: Set when the switch is controlled exlusively by userspace. | |
64 | 61 | * @mutex: Guards switch state transitions. It serializes callbacks |
65 | 62 | * and also protects the state. |
66 | 63 | * @data: Pointer to the RF button drivers private data which will be |
... | ... | @@ -82,9 +79,6 @@ |
82 | 79 | struct rfkill { |
83 | 80 | const char *name; |
84 | 81 | enum rfkill_type type; |
85 | - | |
86 | - bool user_claim_unsupported; | |
87 | - bool user_claim; | |
88 | 82 | |
89 | 83 | /* the mutex serializes callbacks and also protects |
90 | 84 | * the state */ |
net/rfkill/rfkill.c
... | ... | @@ -200,7 +200,7 @@ |
200 | 200 | |
201 | 201 | rfkill_global_states[type].current_state = state; |
202 | 202 | list_for_each_entry(rfkill, &rfkill_list, node) { |
203 | - if ((!rfkill->user_claim) && (rfkill->type == type)) { | |
203 | + if (rfkill->type == type) { | |
204 | 204 | mutex_lock(&rfkill->mutex); |
205 | 205 | rfkill_toggle_radio(rfkill, state, 0); |
206 | 206 | mutex_unlock(&rfkill->mutex); |
207 | 207 | |
... | ... | @@ -447,53 +447,14 @@ |
447 | 447 | struct device_attribute *attr, |
448 | 448 | char *buf) |
449 | 449 | { |
450 | - struct rfkill *rfkill = to_rfkill(dev); | |
451 | - | |
452 | - return sprintf(buf, "%d\n", rfkill->user_claim); | |
450 | + return sprintf(buf, "%d\n", 0); | |
453 | 451 | } |
454 | 452 | |
455 | 453 | static ssize_t rfkill_claim_store(struct device *dev, |
456 | 454 | struct device_attribute *attr, |
457 | 455 | const char *buf, size_t count) |
458 | 456 | { |
459 | - struct rfkill *rfkill = to_rfkill(dev); | |
460 | - unsigned long claim_tmp; | |
461 | - bool claim; | |
462 | - int error; | |
463 | - | |
464 | - if (!capable(CAP_NET_ADMIN)) | |
465 | - return -EPERM; | |
466 | - | |
467 | - if (rfkill->user_claim_unsupported) | |
468 | - return -EOPNOTSUPP; | |
469 | - | |
470 | - error = strict_strtoul(buf, 0, &claim_tmp); | |
471 | - if (error) | |
472 | - return error; | |
473 | - claim = !!claim_tmp; | |
474 | - | |
475 | - /* | |
476 | - * Take the global lock to make sure the kernel is not in | |
477 | - * the middle of rfkill_switch_all | |
478 | - */ | |
479 | - error = mutex_lock_killable(&rfkill_global_mutex); | |
480 | - if (error) | |
481 | - return error; | |
482 | - | |
483 | - if (rfkill->user_claim != claim) { | |
484 | - if (!claim && !rfkill_epo_lock_active) { | |
485 | - mutex_lock(&rfkill->mutex); | |
486 | - rfkill_toggle_radio(rfkill, | |
487 | - rfkill_global_states[rfkill->type].current_state, | |
488 | - 0); | |
489 | - mutex_unlock(&rfkill->mutex); | |
490 | - } | |
491 | - rfkill->user_claim = claim; | |
492 | - } | |
493 | - | |
494 | - mutex_unlock(&rfkill_global_mutex); | |
495 | - | |
496 | - return error ? error : count; | |
457 | + return -EOPNOTSUPP; | |
497 | 458 | } |
498 | 459 | |
499 | 460 | static struct device_attribute rfkill_dev_attrs[] = { |
net/wimax/op-rfkill.c
... | ... | @@ -364,7 +364,6 @@ |
364 | 364 | rfkill->state = RFKILL_STATE_UNBLOCKED; |
365 | 365 | rfkill->data = wimax_dev; |
366 | 366 | rfkill->toggle_radio = wimax_rfkill_toggle_radio; |
367 | - rfkill->user_claim_unsupported = 1; | |
368 | 367 | |
369 | 368 | /* Initialize the input device for the hw key */ |
370 | 369 | input_dev = input_allocate_device(); |