summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwmc3200wifi/rfkill.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwmc3200wifi/rfkill.c')
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rfkill.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/rfkill.c b/drivers/net/wireless/iwmc3200wifi/rfkill.c
index 4ca8b495f82..8ee2c3c09a0 100644
--- a/drivers/net/wireless/iwmc3200wifi/rfkill.c
+++ b/drivers/net/wireless/iwmc3200wifi/rfkill.c
@@ -25,47 +25,42 @@
#include "iwm.h"
-static int iwm_rfkill_soft_toggle(void *data, enum rfkill_state state)
+static int iwm_rfkill_set_block(void *data, bool blocked)
{
struct iwm_priv *iwm = data;
- switch (state) {
- case RFKILL_STATE_UNBLOCKED:
+ if (!blocked) {
if (test_bit(IWM_RADIO_RFKILL_HW, &iwm->radio))
return -EBUSY;
if (test_and_clear_bit(IWM_RADIO_RFKILL_SW, &iwm->radio) &&
(iwm_to_ndev(iwm)->flags & IFF_UP))
- iwm_up(iwm);
-
- break;
- case RFKILL_STATE_SOFT_BLOCKED:
+ return iwm_up(iwm);
+ } else {
if (!test_and_set_bit(IWM_RADIO_RFKILL_SW, &iwm->radio))
- iwm_down(iwm);
-
- break;
- default:
- break;
+ return iwm_down(iwm);
}
return 0;
}
+static const struct rfkill_ops iwm_rfkill_ops = {
+ .set_block = iwm_rfkill_set_block,
+};
+
int iwm_rfkill_init(struct iwm_priv *iwm)
{
int ret;
- iwm->rfkill = rfkill_allocate(iwm_to_dev(iwm), RFKILL_TYPE_WLAN);
+ iwm->rfkill = rfkill_alloc(KBUILD_MODNAME,
+ iwm_to_dev(iwm),
+ RFKILL_TYPE_WLAN,
+ &iwm_rfkill_ops, iwm);
if (!iwm->rfkill) {
IWM_ERR(iwm, "Unable to allocate rfkill device\n");
return -ENOMEM;
}
- iwm->rfkill->name = KBUILD_MODNAME;
- iwm->rfkill->data = iwm;
- iwm->rfkill->state = RFKILL_STATE_UNBLOCKED;
- iwm->rfkill->toggle_radio = iwm_rfkill_soft_toggle;
-
ret = rfkill_register(iwm->rfkill);
if (ret) {
IWM_ERR(iwm, "Failed to register rfkill device\n");
@@ -74,15 +69,15 @@ int iwm_rfkill_init(struct iwm_priv *iwm)
return 0;
fail:
- rfkill_free(iwm->rfkill);
+ rfkill_destroy(iwm->rfkill);
return ret;
}
void iwm_rfkill_exit(struct iwm_priv *iwm)
{
- if (iwm->rfkill)
+ if (iwm->rfkill) {
rfkill_unregister(iwm->rfkill);
-
- rfkill_free(iwm->rfkill);
+ rfkill_destroy(iwm->rfkill);
+ }
iwm->rfkill = NULL;
}