aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43/rfkill.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-06-07 13:30:34 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-10 13:27:54 -0400
commitf41f3f373dd72344c65d801d6381fe83ef3a2c54 (patch)
treefd5a9da51f07d2128fa741032d9f09ce1fa96cfb /drivers/net/wireless/b43/rfkill.c
parente6a3b61681dcb963e6465ffbc4330b44824f35e3 (diff)
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.c113
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 @@
22 22
23*/ 23*/
24 24
25#include "rfkill.h"
26#include "b43.h" 25#include "b43.h"
27#include "phy_common.h"
28
29#include <linux/kmod.h>
30 26
31 27
32/* Returns TRUE, if the radio is enabled in hardware. */ 28/* Returns TRUE, if the radio is enabled in hardware. */
33static bool b43_is_hw_radio_enabled(struct b43_wldev *dev) 29bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
34{ 30{
35 if (dev->phy.rev >= 3) { 31 if (dev->phy.rev >= 3) {
36 if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI) 32 if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
@@ -45,110 +41,39 @@ static bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
45} 41}
46 42
47/* The poll callback for the hardware button. */ 43/* The poll callback for the hardware button. */
48static void b43_rfkill_poll(struct rfkill *rfkill, void *data) 44void b43_rfkill_poll(struct ieee80211_hw *hw)
49{ 45{
50 struct b43_wldev *dev = data; 46 struct b43_wl *wl = hw_to_b43_wl(hw);
51 struct b43_wl *wl = dev->wl; 47 struct b43_wldev *dev = wl->current_dev;
48 struct ssb_bus *bus = dev->dev->bus;
52 bool enabled; 49 bool enabled;
50 bool brought_up = false;
53 51
54 mutex_lock(&wl->mutex); 52 mutex_lock(&wl->mutex);
55 if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) { 53 if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) {
56 mutex_unlock(&wl->mutex); 54 if (ssb_bus_powerup(bus, 0)) {
57 return; 55 mutex_unlock(&wl->mutex);
56 return;
57 }
58 ssb_device_enable(dev->dev, 0);
59 brought_up = true;
58 } 60 }
61
59 enabled = b43_is_hw_radio_enabled(dev); 62 enabled = b43_is_hw_radio_enabled(dev);
63
60 if (unlikely(enabled != dev->radio_hw_enable)) { 64 if (unlikely(enabled != dev->radio_hw_enable)) {
61 dev->radio_hw_enable = enabled; 65 dev->radio_hw_enable = enabled;
62 b43info(wl, "Radio hardware status changed to %s\n", 66 b43info(wl, "Radio hardware status changed to %s\n",
63 enabled ? "ENABLED" : "DISABLED"); 67 enabled ? "ENABLED" : "DISABLED");
64 enabled = !rfkill_set_hw_state(rfkill, !enabled); 68 wiphy_rfkill_set_hw_state(hw->wiphy, !enabled);
65 if (enabled != dev->phy.radio_on) 69 if (enabled != dev->phy.radio_on)
66 b43_software_rfkill(dev, !enabled); 70 b43_software_rfkill(dev, !enabled);
67 } 71 }
68 mutex_unlock(&wl->mutex);
69}
70
71/* Called when the RFKILL toggled in software. */
72static int b43_rfkill_soft_set(void *data, bool blocked)
73{
74 struct b43_wldev *dev = data;
75 struct b43_wl *wl = dev->wl;
76 int err = -EINVAL;
77
78 if (WARN_ON(!wl->rfkill.registered))
79 return -EINVAL;
80 72
81 mutex_lock(&wl->mutex); 73 if (brought_up) {
82 74 ssb_device_disable(dev->dev, 0);
83 if (b43_status(dev) < B43_STAT_INITIALIZED) 75 ssb_bus_may_powerdown(bus);
84 goto out_unlock; 76 }
85
86 if (!dev->radio_hw_enable)
87 goto out_unlock;
88 77
89 if (!blocked != dev->phy.radio_on)
90 b43_software_rfkill(dev, blocked);
91 err = 0;
92out_unlock:
93 mutex_unlock(&wl->mutex); 78 mutex_unlock(&wl->mutex);
94 return err;
95}
96
97const char *b43_rfkill_led_name(struct b43_wldev *dev)
98{
99 struct b43_rfkill *rfk = &(dev->wl->rfkill);
100
101 if (!rfk->registered)
102 return NULL;
103 return rfkill_get_led_trigger_name(rfk->rfkill);
104}
105
106static const struct rfkill_ops b43_rfkill_ops = {
107 .set_block = b43_rfkill_soft_set,
108 .poll = b43_rfkill_poll,
109};
110
111void b43_rfkill_init(struct b43_wldev *dev)
112{
113 struct b43_wl *wl = dev->wl;
114 struct b43_rfkill *rfk = &(wl->rfkill);
115 int err;
116
117 rfk->registered = 0;
118
119 snprintf(rfk->name, sizeof(rfk->name),
120 "b43-%s", wiphy_name(wl->hw->wiphy));
121
122 rfk->rfkill = rfkill_alloc(rfk->name,
123 dev->dev->dev,
124 RFKILL_TYPE_WLAN,
125 &b43_rfkill_ops, dev);
126 if (!rfk->rfkill)
127 goto out_error;
128
129 err = rfkill_register(rfk->rfkill);
130 if (err)
131 goto err_free;
132
133 rfk->registered = 1;
134
135 return;
136 err_free:
137 rfkill_destroy(rfk->rfkill);
138 out_error:
139 rfk->registered = 0;
140 b43warn(wl, "RF-kill button init failed\n");
141}
142
143void b43_rfkill_exit(struct b43_wldev *dev)
144{
145 struct b43_rfkill *rfk = &(dev->wl->rfkill);
146
147 if (!rfk->registered)
148 return;
149 rfk->registered = 0;
150
151 rfkill_unregister(rfk->rfkill);
152 rfkill_destroy(rfk->rfkill);
153 rfk->rfkill = NULL;
154} 79}