summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/iwmc3200wifi/rfkill.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-06-02 11:01:37 (GMT)
committerJohn W. Linville <linville@tuxdriver.com>2009-06-03 18:06:13 (GMT)
commit19d337dff95cbf76edd3ad95c0cee2732c3e1ec5 (patch)
tree33326eeb09cb9664cc8427a5dc7cd2b08b5a57c3 /drivers/net/wireless/iwmc3200wifi/rfkill.c
parent0f6399c4c525b518644a9b09f8d6fb125a418c4d (diff)
downloadlinux-fsl-qoriq-19d337dff95cbf76edd3ad95c0cee2732c3e1ec5.tar.xz
rfkill: rewrite
This patch completely rewrites the rfkill core to address the following deficiencies: * all rfkill drivers need to implement polling where necessary rather than having one central implementation * updating the rfkill state cannot be done from arbitrary contexts, forcing drivers to use schedule_work and requiring lots of code * rfkill drivers need to keep track of soft/hard blocked internally -- the core should do this * the rfkill API has many unexpected quirks, for example being asymmetric wrt. alloc/free and register/unregister * rfkill can call back into a driver from within a function the driver called -- this is prone to deadlocks and generally should be avoided * rfkill-input pointlessly is a separate module * drivers need to #ifdef rfkill functions (unless they want to depend on or select RFKILL) -- rfkill should provide inlines that do nothing if it isn't compiled in * the rfkill structure is not opaque -- drivers need to initialise it correctly (lots of sanity checking code required) -- instead force drivers to pass the right variables to rfkill_alloc() * the documentation is hard to read because it always assumes the reader is completely clueless and contains way TOO MANY CAPS * the rfkill code needlessly uses a lot of locks and atomic operations in locked sections * fix LED trigger to actually change the LED when the radio state changes -- this wasn't done before Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk> Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> [thinkpad] Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
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 4ca8b49..8ee2c3c 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;
}