rfkill: remove user_claim stuff
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 27 Mar 2009 13:14:31 +0000 (14:14 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 22 Apr 2009 20:54:27 +0000 (16:54 -0400)
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>
12 files changed:
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

index 4d3ee317a4a3e84181047ab417a3e2a88c4995bc..40c3a3f10816677c8f5b65282818369f63dbe255 100644 (file)
@@ -521,16 +521,12 @@ status of the system.
 Input devices may issue events that are related to rfkill.  These are the
 various KEY_* events and SW_* events supported by rfkill-input.c.
 
-******IMPORTANT******
-When rfkill-input is ACTIVE, userspace is NOT TO CHANGE THE STATE OF AN RFKILL
-SWITCH IN RESPONSE TO AN INPUT EVENT also handled by rfkill-input, unless it
-has set to true the user_claim attribute for that particular switch.  This rule
-is *absolute*; do NOT violate it.
-******IMPORTANT******
-
-Userspace must not assume it is the only source of control for rfkill switches.
-Their state CAN and WILL change due to firmware actions, direct user actions,
-and the rfkill-input EPO override for *_RFKILL_ALL.
+Userspace may not change the state of an rfkill switch in response to an
+input event, it should refrain from changing states entirely.
+
+Userspace cannot assume it is the only source of control for rfkill switches.
+Their state can change due to firmware actions, direct user actions, and the
+rfkill-input EPO override for *_RFKILL_ALL.
 
 When rfkill-input is not active, userspace must initiate a rfkill status
 change by writing to the "state" attribute in order for anything to happen.
index 13d4e6756c9973e57eeb6243ad8f757a07d463a3..0607df20e497f87f0b4637bed7c6bcd39838da01 100644 (file)
@@ -1267,7 +1267,6 @@ static int ath_init_sw_rfkill(struct ath_softc *sc)
        sc->rf_kill.rfkill->data = sc;
        sc->rf_kill.rfkill->toggle_radio = ath_sw_toggle_radio;
        sc->rf_kill.rfkill->state = RFKILL_STATE_UNBLOCKED;
-       sc->rf_kill.rfkill->user_claim_unsupported = 1;
 
        return 0;
 }
index afad423586931ed618c6ea32445c4df17987b0e2..9e1d00bc24d3f23b69f532f87b23d540ab47d0d9 100644 (file)
@@ -139,7 +139,6 @@ void b43_rfkill_init(struct b43_wldev *dev)
        rfk->rfkill->state = RFKILL_STATE_UNBLOCKED;
        rfk->rfkill->data = dev;
        rfk->rfkill->toggle_radio = b43_rfkill_soft_toggle;
-       rfk->rfkill->user_claim_unsupported = 1;
 
        rfk->poll_dev = input_allocate_polled_device();
        if (!rfk->poll_dev) {
index b32bf6a94f19d7543525ed562a89683bf893d168..4b0c7d27a51f90374887d20a1974191f49c40bef 100644 (file)
@@ -142,7 +142,6 @@ void b43legacy_rfkill_init(struct b43legacy_wldev *dev)
        rfk->rfkill->state = RFKILL_STATE_UNBLOCKED;
        rfk->rfkill->data = dev;
        rfk->rfkill->toggle_radio = b43legacy_rfkill_soft_toggle;
-       rfk->rfkill->user_claim_unsupported = 1;
 
        rfk->poll_dev = input_allocate_polled_device();
        if (!rfk->poll_dev) {
index 2ad9faf1508a702e23462891355abdfc07cf69c7..65605ad44e4b0c06e16ccd3141a03190003d4c7e 100644 (file)
@@ -91,7 +91,6 @@ int iwl_rfkill_init(struct iwl_priv *priv)
        priv->rfkill->data = priv;
        priv->rfkill->state = RFKILL_STATE_UNBLOCKED;
        priv->rfkill->toggle_radio = iwl_rfkill_soft_rf_kill;
-       priv->rfkill->user_claim_unsupported = 1;
 
        priv->rfkill->dev.class->suspend = NULL;
        priv->rfkill->dev.class->resume = NULL;
index 0f6e43bf4fc211804272790d409e18daeba128fa..62d02b3c998ef80e4fe26e9f1f9167f563664adc 100644 (file)
@@ -1005,7 +1005,6 @@ enum rfkill_type type, char *name, u32 cap)
        *data = cap;
        rfkill_dev->data = data;
        rfkill_dev->toggle_radio = acer_rfkill_set;
-       rfkill_dev->user_claim_unsupported = 1;
 
        err = rfkill_register(rfkill_dev);
        if (err) {
index 50d9019de2be2b33beae302ef0d99480073c0b52..fe171fad12cf723c140d9098fe39172b4832bed0 100644 (file)
@@ -434,7 +434,6 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                wifi_rfkill->name = "hp-wifi";
                wifi_rfkill->state = hp_wmi_wifi_state();
                wifi_rfkill->toggle_radio = hp_wmi_wifi_set;
-               wifi_rfkill->user_claim_unsupported = 1;
                err = rfkill_register(wifi_rfkill);
                if (err)
                        goto add_sysfs_error;
@@ -446,7 +445,6 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                bluetooth_rfkill->name = "hp-bluetooth";
                bluetooth_rfkill->state = hp_wmi_bluetooth_state();
                bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
-               bluetooth_rfkill->user_claim_unsupported = 1;
                err = rfkill_register(bluetooth_rfkill);
                if (err)
                        goto register_bluetooth_error;
@@ -457,7 +455,6 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                wwan_rfkill->name = "hp-wwan";
                wwan_rfkill->state = hp_wmi_wwan_state();
                wwan_rfkill->toggle_radio = hp_wmi_wwan_set;
-               wwan_rfkill->user_claim_unsupported = 1;
                err = rfkill_register(wwan_rfkill);
                if (err)
                        goto register_wwan_err;
index d3c92d777bde343d95f733ad62f34a20e91da533..184e99e72684d27487917f23251599fdfceb94d0 100644 (file)
@@ -1097,7 +1097,6 @@ static int sony_nc_setup_wifi_rfkill(struct acpi_device *device)
        sony_wifi_rfkill->name = "sony-wifi";
        sony_wifi_rfkill->toggle_radio = sony_nc_rfkill_set;
        sony_wifi_rfkill->get_state = sony_nc_rfkill_get;
-       sony_wifi_rfkill->user_claim_unsupported = 1;
        sony_wifi_rfkill->data = (void *)SONY_WIFI;
        err = rfkill_register(sony_wifi_rfkill);
        if (err)
@@ -1119,7 +1118,6 @@ static int sony_nc_setup_bluetooth_rfkill(struct acpi_device *device)
        sony_bluetooth_rfkill->name = "sony-bluetooth";
        sony_bluetooth_rfkill->toggle_radio = sony_nc_rfkill_set;
        sony_bluetooth_rfkill->get_state = sony_nc_rfkill_get;
-       sony_bluetooth_rfkill->user_claim_unsupported = 1;
        sony_bluetooth_rfkill->data = (void *)SONY_BLUETOOTH;
        err = rfkill_register(sony_bluetooth_rfkill);
        if (err)
@@ -1140,7 +1138,6 @@ static int sony_nc_setup_wwan_rfkill(struct acpi_device *device)
        sony_wwan_rfkill->name = "sony-wwan";
        sony_wwan_rfkill->toggle_radio = sony_nc_rfkill_set;
        sony_wwan_rfkill->get_state = sony_nc_rfkill_get;
-       sony_wwan_rfkill->user_claim_unsupported = 1;
        sony_wwan_rfkill->data = (void *)SONY_WWAN;
        err = rfkill_register(sony_wwan_rfkill);
        if (err)
@@ -1161,7 +1158,6 @@ static int sony_nc_setup_wimax_rfkill(struct acpi_device *device)
        sony_wimax_rfkill->name = "sony-wimax";
        sony_wimax_rfkill->toggle_radio = sony_nc_rfkill_set;
        sony_wimax_rfkill->get_state = sony_nc_rfkill_get;
-       sony_wimax_rfkill->user_claim_unsupported = 1;
        sony_wimax_rfkill->data = (void *)SONY_WIMAX;
        err = rfkill_register(sony_wimax_rfkill);
        if (err)
index 9f187265db8e260d201b167bc0095e8bd4757765..4345089f51719d84817ace6194d3ffb1ef79c6d4 100644 (file)
@@ -803,7 +803,6 @@ static int __init toshiba_acpi_init(void)
 
                toshiba_acpi.rfk_dev->name = toshiba_acpi.bt_name;
                toshiba_acpi.rfk_dev->toggle_radio = bt_rfkill_toggle_radio;
-               toshiba_acpi.rfk_dev->user_claim_unsupported = 1;
                toshiba_acpi.rfk_dev->data = &toshiba_acpi;
 
                if (hci_get_bt_on(&bt_on) == HCI_SUCCESS && bt_on) {
index e1ec7d9aa49cc81d6b09a28a30adc47edf5727e4..de18ef227e00452c5c806e4d97d9da13772e32b9 100644 (file)
@@ -58,9 +58,6 @@ enum rfkill_state {
  * @type: Radio type which the button controls, the value stored
  *     here should be a value from enum rfkill_type.
  * @state: State of the switch, "UNBLOCKED" means radio can operate.
- * @user_claim_unsupported: Whether the hardware supports exclusive
- *     RF-kill control by userspace. Set this before registering.
- * @user_claim: Set when the switch is controlled exlusively by userspace.
  * @mutex: Guards switch state transitions.  It serializes callbacks
  *     and also protects the state.
  * @data: Pointer to the RF button drivers private data which will be
@@ -83,9 +80,6 @@ struct rfkill {
        const char *name;
        enum rfkill_type type;
 
-       bool user_claim_unsupported;
-       bool user_claim;
-
        /* the mutex serializes callbacks and also protects
         * the state */
        struct mutex mutex;
index 3eaa39403c13e447d4b4603c8c9f7f75d77ca252..df1269c5ca70e3bf83ab1374931bf2fe8074e956 100644 (file)
@@ -200,7 +200,7 @@ static void __rfkill_switch_all(const enum rfkill_type type,
 
        rfkill_global_states[type].current_state = state;
        list_for_each_entry(rfkill, &rfkill_list, node) {
-               if ((!rfkill->user_claim) && (rfkill->type == type)) {
+               if (rfkill->type == type) {
                        mutex_lock(&rfkill->mutex);
                        rfkill_toggle_radio(rfkill, state, 0);
                        mutex_unlock(&rfkill->mutex);
@@ -447,53 +447,14 @@ static ssize_t rfkill_claim_show(struct device *dev,
                                 struct device_attribute *attr,
                                 char *buf)
 {
-       struct rfkill *rfkill = to_rfkill(dev);
-
-       return sprintf(buf, "%d\n", rfkill->user_claim);
+       return sprintf(buf, "%d\n", 0);
 }
 
 static ssize_t rfkill_claim_store(struct device *dev,
                                  struct device_attribute *attr,
                                  const char *buf, size_t count)
 {
-       struct rfkill *rfkill = to_rfkill(dev);
-       unsigned long claim_tmp;
-       bool claim;
-       int error;
-
-       if (!capable(CAP_NET_ADMIN))
-               return -EPERM;
-
-       if (rfkill->user_claim_unsupported)
-               return -EOPNOTSUPP;
-
-       error = strict_strtoul(buf, 0, &claim_tmp);
-       if (error)
-               return error;
-       claim = !!claim_tmp;
-
-       /*
-        * Take the global lock to make sure the kernel is not in
-        * the middle of rfkill_switch_all
-        */
-       error = mutex_lock_killable(&rfkill_global_mutex);
-       if (error)
-               return error;
-
-       if (rfkill->user_claim != claim) {
-               if (!claim && !rfkill_epo_lock_active) {
-                       mutex_lock(&rfkill->mutex);
-                       rfkill_toggle_radio(rfkill,
-                                       rfkill_global_states[rfkill->type].current_state,
-                                       0);
-                       mutex_unlock(&rfkill->mutex);
-               }
-               rfkill->user_claim = claim;
-       }
-
-       mutex_unlock(&rfkill_global_mutex);
-
-       return error ? error : count;
+       return -EOPNOTSUPP;
 }
 
 static struct device_attribute rfkill_dev_attrs[] = {
index 870032faece25e39863ba13f6e9893da1f85a47a..a3616e2ccb8a6d7f20a45a95fdf01fe826479270 100644 (file)
@@ -364,7 +364,6 @@ int wimax_rfkill_add(struct wimax_dev *wimax_dev)
        rfkill->state = RFKILL_STATE_UNBLOCKED;
        rfkill->data = wimax_dev;
        rfkill->toggle_radio = wimax_rfkill_toggle_radio;
-       rfkill->user_claim_unsupported = 1;
 
        /* Initialize the input device for the hw key */
        input_dev = input_allocate_device();