summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43legacy/rfkill.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-06-07 12:30:34 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-06-10 13:27:54 -0400
commitf41f3f373dd72344c65d801d6381fe83ef3a2c54 (patch)
treefd5a9da51f07d2128fa741032d9f09ce1fa96cfb /drivers/net/wireless/b43legacy/rfkill.c
parente6a3b61681dcb963e6465ffbc4330b44824f35e3 (diff)
downloadblackbird-op-linux-f41f3f373dd72344c65d801d6381fe83ef3a2c54.tar.gz
blackbird-op-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/b43legacy/rfkill.c')
-rw-r--r--drivers/net/wireless/b43legacy/rfkill.c115
1 files changed, 18 insertions, 97 deletions
diff --git a/drivers/net/wireless/b43legacy/rfkill.c b/drivers/net/wireless/b43legacy/rfkill.c
index c6230a64505a..8783022db11e 100644
--- a/drivers/net/wireless/b43legacy/rfkill.c
+++ b/drivers/net/wireless/b43legacy/rfkill.c
@@ -22,15 +22,12 @@
*/
-#include "rfkill.h"
#include "radio.h"
#include "b43legacy.h"
-#include <linux/kmod.h>
-
/* Returns TRUE, if the radio is enabled in hardware. */
-static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
+bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
{
if (dev->phy.rev >= 3) {
if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI)
@@ -45,23 +42,31 @@ static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
}
/* The poll callback for the hardware button. */
-static void b43legacy_rfkill_poll(struct rfkill *rfkill, void *data)
+void b43legacy_rfkill_poll(struct ieee80211_hw *hw)
{
- struct b43legacy_wldev *dev = data;
- struct b43legacy_wl *wl = dev->wl;
+ struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
+ struct b43legacy_wldev *dev = wl->current_dev;
+ struct ssb_bus *bus = dev->dev->bus;
bool enabled;
+ bool brought_up = false;
mutex_lock(&wl->mutex);
if (unlikely(b43legacy_status(dev) < B43legacy_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 = b43legacy_is_hw_radio_enabled(dev);
+
if (unlikely(enabled != dev->radio_hw_enable)) {
dev->radio_hw_enable = enabled;
b43legacyinfo(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) {
if (enabled)
b43legacy_radio_turn_on(dev);
@@ -69,95 +74,11 @@ static void b43legacy_rfkill_poll(struct rfkill *rfkill, void *data)
b43legacy_radio_turn_off(dev, 0);
}
}
- mutex_unlock(&wl->mutex);
-}
-
-/* Called when the RFKILL toggled in software.
- * This is called without locking. */
-static int b43legacy_rfkill_soft_set(void *data, bool blocked)
-{
- struct b43legacy_wldev *dev = data;
- struct b43legacy_wl *wl = dev->wl;
- int ret = -EINVAL;
- if (!wl->rfkill.registered)
- return -EINVAL;
-
- mutex_lock(&wl->mutex);
- if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)
- goto out_unlock;
-
- if (!dev->radio_hw_enable)
- goto out_unlock;
-
- if (!blocked != dev->phy.radio_on) {
- if (!blocked)
- b43legacy_radio_turn_on(dev);
- else
- b43legacy_radio_turn_off(dev, 0);
+ if (brought_up) {
+ ssb_device_disable(dev->dev, 0);
+ ssb_bus_may_powerdown(bus);
}
- ret = 0;
-out_unlock:
mutex_unlock(&wl->mutex);
- return ret;
-}
-
-const char *b43legacy_rfkill_led_name(struct b43legacy_wldev *dev)
-{
- struct b43legacy_rfkill *rfk = &(dev->wl->rfkill);
-
- if (!rfk->registered)
- return NULL;
- return rfkill_get_led_trigger_name(rfk->rfkill);
}
-
-static const struct rfkill_ops b43legacy_rfkill_ops = {
- .set_block = b43legacy_rfkill_soft_set,
- .poll = b43legacy_rfkill_poll,
-};
-
-void b43legacy_rfkill_init(struct b43legacy_wldev *dev)
-{
- struct b43legacy_wl *wl = dev->wl;
- struct b43legacy_rfkill *rfk = &(wl->rfkill);
- int err;
-
- rfk->registered = 0;
-
- snprintf(rfk->name, sizeof(rfk->name),
- "b43legacy-%s", wiphy_name(wl->hw->wiphy));
- rfk->rfkill = rfkill_alloc(rfk->name,
- dev->dev->dev,
- RFKILL_TYPE_WLAN,
- &b43legacy_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;
- b43legacywarn(wl, "RF-kill button init failed\n");
-}
-
-void b43legacy_rfkill_exit(struct b43legacy_wldev *dev)
-{
- struct b43legacy_rfkill *rfk = &(dev->wl->rfkill);
-
- if (!rfk->registered)
- return;
- rfk->registered = 0;
-
- rfkill_unregister(rfk->rfkill);
- rfkill_destroy(rfk->rfkill);
- rfk->rfkill = NULL;
-}
-
OpenPOWER on IntegriCloud