diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-06-07 19:30:34 +0200 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-06-10 19:27:54 +0200 |
commit | f41f3f373dd72344c65d801d6381fe83ef3a2c54 (patch) | |
tree | fd5a9da51f07d2128fa741032d9f09ce1fa96cfb /drivers/net/wireless/b43/rfkill.c | |
parent | ath5k: added cfg80211 based rfkill support (diff) | |
download | linux-f41f3f373dd72344c65d801d6381fe83ef3a2c54.tar.xz linux-f41f3f373dd72344c65d801d6381fe83ef3a2c54.zip |
b43/legacy: port to cfg80211 rfkill
This ports the b43/legacy rfkill code to the new API offered
by cfg80211 and thus removes a lot of useless stuff.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43/rfkill.c')
-rw-r--r-- | drivers/net/wireless/b43/rfkill.c | 113 |
1 files changed, 19 insertions, 94 deletions
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c index 96047843cd56..31e55999893f 100644 --- a/drivers/net/wireless/b43/rfkill.c +++ b/drivers/net/wireless/b43/rfkill.c @@ -22,15 +22,11 @@ */ -#include "rfkill.h" #include "b43.h" -#include "phy_common.h" - -#include <linux/kmod.h> /* Returns TRUE, if the radio is enabled in hardware. */ -static bool b43_is_hw_radio_enabled(struct b43_wldev *dev) +bool b43_is_hw_radio_enabled(struct b43_wldev *dev) { if (dev->phy.rev >= 3) { if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI) @@ -45,110 +41,39 @@ static bool b43_is_hw_radio_enabled(struct b43_wldev *dev) } /* The poll callback for the hardware button. */ -static void b43_rfkill_poll(struct rfkill *rfkill, void *data) +void b43_rfkill_poll(struct ieee80211_hw *hw) { - struct b43_wldev *dev = data; - struct b43_wl *wl = dev->wl; + struct b43_wl *wl = hw_to_b43_wl(hw); + struct b43_wldev *dev = wl->current_dev; + struct ssb_bus *bus = dev->dev->bus; bool enabled; + bool brought_up = false; mutex_lock(&wl->mutex); if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) { - mutex_unlock(&wl->mutex); - return; + if (ssb_bus_powerup(bus, 0)) { + mutex_unlock(&wl->mutex); + return; + } + ssb_device_enable(dev->dev, 0); + brought_up = true; } + enabled = b43_is_hw_radio_enabled(dev); + if (unlikely(enabled != dev->radio_hw_enable)) { dev->radio_hw_enable = enabled; b43info(wl, "Radio hardware status changed to %s\n", enabled ? "ENABLED" : "DISABLED"); - enabled = !rfkill_set_hw_state(rfkill, !enabled); + wiphy_rfkill_set_hw_state(hw->wiphy, !enabled); if (enabled != dev->phy.radio_on) b43_software_rfkill(dev, !enabled); } - mutex_unlock(&wl->mutex); -} - -/* Called when the RFKILL toggled in software. */ -static int b43_rfkill_soft_set(void *data, bool blocked) -{ - struct b43_wldev *dev = data; - struct b43_wl *wl = dev->wl; - int err = -EINVAL; - - if (WARN_ON(!wl->rfkill.registered)) - return -EINVAL; - mutex_lock(&wl->mutex); - - if (b43_status(dev) < B43_STAT_INITIALIZED) - goto out_unlock; - - if (!dev->radio_hw_enable) - goto out_unlock; + if (brought_up) { + ssb_device_disable(dev->dev, 0); + ssb_bus_may_powerdown(bus); + } - if (!blocked != dev->phy.radio_on) - b43_software_rfkill(dev, blocked); - err = 0; -out_unlock: mutex_unlock(&wl->mutex); - return err; -} - -const char *b43_rfkill_led_name(struct b43_wldev *dev) -{ - struct b43_rfkill *rfk = &(dev->wl->rfkill); - - if (!rfk->registered) - return NULL; - return rfkill_get_led_trigger_name(rfk->rfkill); -} - -static const struct rfkill_ops b43_rfkill_ops = { - .set_block = b43_rfkill_soft_set, - .poll = b43_rfkill_poll, -}; - -void b43_rfkill_init(struct b43_wldev *dev) -{ - struct b43_wl *wl = dev->wl; - struct b43_rfkill *rfk = &(wl->rfkill); - int err; - - rfk->registered = 0; - - snprintf(rfk->name, sizeof(rfk->name), - "b43-%s", wiphy_name(wl->hw->wiphy)); - - rfk->rfkill = rfkill_alloc(rfk->name, - dev->dev->dev, - RFKILL_TYPE_WLAN, - &b43_rfkill_ops, dev); - if (!rfk->rfkill) - goto out_error; - - err = rfkill_register(rfk->rfkill); - if (err) - goto err_free; - - rfk->registered = 1; - - return; - err_free: - rfkill_destroy(rfk->rfkill); - out_error: - rfk->registered = 0; - b43warn(wl, "RF-kill button init failed\n"); -} - -void b43_rfkill_exit(struct b43_wldev *dev) -{ - struct b43_rfkill *rfk = &(dev->wl->rfkill); - - if (!rfk->registered) - return; - rfk->registered = 0; - - rfkill_unregister(rfk->rfkill); - rfkill_destroy(rfk->rfkill); - rfk->rfkill = NULL; } |