aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43legacy
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/b43legacy
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/b43legacy')
-rw-r--r--drivers/net/wireless/b43legacy/Kconfig8
-rw-r--r--drivers/net/wireless/b43legacy/Makefile2
-rw-r--r--drivers/net/wireless/b43legacy/b43legacy.h3
-rw-r--r--drivers/net/wireless/b43legacy/leds.c7
-rw-r--r--drivers/net/wireless/b43legacy/main.c17
-rw-r--r--drivers/net/wireless/b43legacy/rfkill.c115
-rw-r--r--drivers/net/wireless/b43legacy/rfkill.h50
7 files changed, 30 insertions, 172 deletions
diff --git a/drivers/net/wireless/b43legacy/Kconfig b/drivers/net/wireless/b43legacy/Kconfig
index 6893f439df70..94a463478053 100644
--- a/drivers/net/wireless/b43legacy/Kconfig
+++ b/drivers/net/wireless/b43legacy/Kconfig
@@ -42,14 +42,6 @@ config B43LEGACY_LEDS
42 depends on B43LEGACY && MAC80211_LEDS && (LEDS_CLASS = y || LEDS_CLASS = B43LEGACY) 42 depends on B43LEGACY && MAC80211_LEDS && (LEDS_CLASS = y || LEDS_CLASS = B43LEGACY)
43 default y 43 default y
44 44
45# RFKILL support
46# This config option automatically enables b43legacy RFKILL support,
47# if it's possible.
48config B43LEGACY_RFKILL
49 bool
50 depends on B43LEGACY && (RFKILL = y || RFKILL = B43LEGACY)
51 default y
52
53# This config option automatically enables b43 HW-RNG support, 45# This config option automatically enables b43 HW-RNG support,
54# if the HW-RNG core is enabled. 46# if the HW-RNG core is enabled.
55config B43LEGACY_HWRNG 47config B43LEGACY_HWRNG
diff --git a/drivers/net/wireless/b43legacy/Makefile b/drivers/net/wireless/b43legacy/Makefile
index 80cdb73bd140..227a77e84362 100644
--- a/drivers/net/wireless/b43legacy/Makefile
+++ b/drivers/net/wireless/b43legacy/Makefile
@@ -6,7 +6,7 @@ b43legacy-y += radio.o
6b43legacy-y += sysfs.o 6b43legacy-y += sysfs.o
7b43legacy-y += xmit.o 7b43legacy-y += xmit.o
8# b43 RFKILL button support 8# b43 RFKILL button support
9b43legacy-$(CONFIG_B43LEGACY_RFKILL) += rfkill.o 9b43legacy-y += rfkill.o
10# b43legacy LED support 10# b43legacy LED support
11b43legacy-$(CONFIG_B43LEGACY_LEDS) += leds.o 11b43legacy-$(CONFIG_B43LEGACY_LEDS) += leds.o
12# b43legacy debugging 12# b43legacy debugging
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h
index 19a4b0bc0d87..77fda148ac46 100644
--- a/drivers/net/wireless/b43legacy/b43legacy.h
+++ b/drivers/net/wireless/b43legacy/b43legacy.h
@@ -602,9 +602,6 @@ struct b43legacy_wl {
602 char rng_name[30 + 1]; 602 char rng_name[30 + 1];
603#endif 603#endif
604 604
605 /* The RF-kill button */
606 struct b43legacy_rfkill rfkill;
607
608 /* List of all wireless devices on this chip */ 605 /* List of all wireless devices on this chip */
609 struct list_head devlist; 606 struct list_head devlist;
610 u8 nr_devs; 607 u8 nr_devs;
diff --git a/drivers/net/wireless/b43legacy/leds.c b/drivers/net/wireless/b43legacy/leds.c
index 538d3117594b..37e9be893560 100644
--- a/drivers/net/wireless/b43legacy/leds.c
+++ b/drivers/net/wireless/b43legacy/leds.c
@@ -28,6 +28,7 @@
28 28
29#include "b43legacy.h" 29#include "b43legacy.h"
30#include "leds.h" 30#include "leds.h"
31#include "rfkill.h"
31 32
32 33
33static void b43legacy_led_turn_on(struct b43legacy_wldev *dev, u8 led_index, 34static void b43legacy_led_turn_on(struct b43legacy_wldev *dev, u8 led_index,
@@ -164,10 +165,10 @@ static void b43legacy_map_led(struct b43legacy_wldev *dev,
164 snprintf(name, sizeof(name), 165 snprintf(name, sizeof(name),
165 "b43legacy-%s::radio", wiphy_name(hw->wiphy)); 166 "b43legacy-%s::radio", wiphy_name(hw->wiphy));
166 b43legacy_register_led(dev, &dev->led_radio, name, 167 b43legacy_register_led(dev, &dev->led_radio, name,
167 b43legacy_rfkill_led_name(dev), 168 ieee80211_get_radio_led_name(hw),
168 led_index, activelow); 169 led_index, activelow);
169 /* Sync the RF-kill LED state with the switch state. */ 170 /* Sync the RF-kill LED state with radio and switch states. */
170 if (dev->radio_hw_enable) 171 if (dev->phy.radio_on && b43legacy_is_hw_radio_enabled(dev))
171 b43legacy_led_turn_on(dev, led_index, activelow); 172 b43legacy_led_turn_on(dev, led_index, activelow);
172 break; 173 break;
173 case B43legacy_LED_WEIRD: 174 case B43legacy_LED_WEIRD:
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index f6f3fbf0a2f4..e5136fb65ddd 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -3431,11 +3431,6 @@ static int b43legacy_op_start(struct ieee80211_hw *hw)
3431 struct b43legacy_wldev *dev = wl->current_dev; 3431 struct b43legacy_wldev *dev = wl->current_dev;
3432 int did_init = 0; 3432 int did_init = 0;
3433 int err = 0; 3433 int err = 0;
3434 bool do_rfkill_exit = 0;
3435
3436 /* First register RFkill.
3437 * LEDs that are registered later depend on it. */
3438 b43legacy_rfkill_init(dev);
3439 3434
3440 /* Kill all old instance specific information to make sure 3435 /* Kill all old instance specific information to make sure
3441 * the card won't use it in the short timeframe between start 3436 * the card won't use it in the short timeframe between start
@@ -3451,10 +3446,8 @@ static int b43legacy_op_start(struct ieee80211_hw *hw)
3451 3446
3452 if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) { 3447 if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) {
3453 err = b43legacy_wireless_core_init(dev); 3448 err = b43legacy_wireless_core_init(dev);
3454 if (err) { 3449 if (err)
3455 do_rfkill_exit = 1;
3456 goto out_mutex_unlock; 3450 goto out_mutex_unlock;
3457 }
3458 did_init = 1; 3451 did_init = 1;
3459 } 3452 }
3460 3453
@@ -3463,17 +3456,15 @@ static int b43legacy_op_start(struct ieee80211_hw *hw)
3463 if (err) { 3456 if (err) {
3464 if (did_init) 3457 if (did_init)
3465 b43legacy_wireless_core_exit(dev); 3458 b43legacy_wireless_core_exit(dev);
3466 do_rfkill_exit = 1;
3467 goto out_mutex_unlock; 3459 goto out_mutex_unlock;
3468 } 3460 }
3469 } 3461 }
3470 3462
3463 wiphy_rfkill_start_polling(hw->wiphy);
3464
3471out_mutex_unlock: 3465out_mutex_unlock:
3472 mutex_unlock(&wl->mutex); 3466 mutex_unlock(&wl->mutex);
3473 3467
3474 if (do_rfkill_exit)
3475 b43legacy_rfkill_exit(dev);
3476
3477 return err; 3468 return err;
3478} 3469}
3479 3470
@@ -3482,7 +3473,6 @@ static void b43legacy_op_stop(struct ieee80211_hw *hw)
3482 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); 3473 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3483 struct b43legacy_wldev *dev = wl->current_dev; 3474 struct b43legacy_wldev *dev = wl->current_dev;
3484 3475
3485 b43legacy_rfkill_exit(dev);
3486 cancel_work_sync(&(wl->beacon_update_trigger)); 3476 cancel_work_sync(&(wl->beacon_update_trigger));
3487 3477
3488 mutex_lock(&wl->mutex); 3478 mutex_lock(&wl->mutex);
@@ -3518,6 +3508,7 @@ static const struct ieee80211_ops b43legacy_hw_ops = {
3518 .start = b43legacy_op_start, 3508 .start = b43legacy_op_start,
3519 .stop = b43legacy_op_stop, 3509 .stop = b43legacy_op_stop,
3520 .set_tim = b43legacy_op_beacon_set_tim, 3510 .set_tim = b43legacy_op_beacon_set_tim,
3511 .rfkill_poll = b43legacy_rfkill_poll,
3521}; 3512};
3522 3513
3523/* Hard-reset the chip. Do not call this directly. 3514/* Hard-reset the chip. Do not call this directly.
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 @@
22 22
23*/ 23*/
24 24
25#include "rfkill.h"
26#include "radio.h" 25#include "radio.h"
27#include "b43legacy.h" 26#include "b43legacy.h"
28 27
29#include <linux/kmod.h>
30
31 28
32/* Returns TRUE, if the radio is enabled in hardware. */ 29/* Returns TRUE, if the radio is enabled in hardware. */
33static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev) 30bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
34{ 31{
35 if (dev->phy.rev >= 3) { 32 if (dev->phy.rev >= 3) {
36 if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI) 33 if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI)
@@ -45,23 +42,31 @@ static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
45} 42}
46 43
47/* The poll callback for the hardware button. */ 44/* The poll callback for the hardware button. */
48static void b43legacy_rfkill_poll(struct rfkill *rfkill, void *data) 45void b43legacy_rfkill_poll(struct ieee80211_hw *hw)
49{ 46{
50 struct b43legacy_wldev *dev = data; 47 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
51 struct b43legacy_wl *wl = dev->wl; 48 struct b43legacy_wldev *dev = wl->current_dev;
49 struct ssb_bus *bus = dev->dev->bus;
52 bool enabled; 50 bool enabled;
51 bool brought_up = false;
53 52
54 mutex_lock(&wl->mutex); 53 mutex_lock(&wl->mutex);
55 if (unlikely(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)) { 54 if (unlikely(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)) {
56 mutex_unlock(&wl->mutex); 55 if (ssb_bus_powerup(bus, 0)) {
57 return; 56 mutex_unlock(&wl->mutex);
57 return;
58 }
59 ssb_device_enable(dev->dev, 0);
60 brought_up = true;
58 } 61 }
62
59 enabled = b43legacy_is_hw_radio_enabled(dev); 63 enabled = b43legacy_is_hw_radio_enabled(dev);
64
60 if (unlikely(enabled != dev->radio_hw_enable)) { 65 if (unlikely(enabled != dev->radio_hw_enable)) {
61 dev->radio_hw_enable = enabled; 66 dev->radio_hw_enable = enabled;
62 b43legacyinfo(wl, "Radio hardware status changed to %s\n", 67 b43legacyinfo(wl, "Radio hardware status changed to %s\n",
63 enabled ? "ENABLED" : "DISABLED"); 68 enabled ? "ENABLED" : "DISABLED");
64 enabled = !rfkill_set_hw_state(rfkill, !enabled); 69 wiphy_rfkill_set_hw_state(hw->wiphy, !enabled);
65 if (enabled != dev->phy.radio_on) { 70 if (enabled != dev->phy.radio_on) {
66 if (enabled) 71 if (enabled)
67 b43legacy_radio_turn_on(dev); 72 b43legacy_radio_turn_on(dev);
@@ -69,95 +74,11 @@ static void b43legacy_rfkill_poll(struct rfkill *rfkill, void *data)
69 b43legacy_radio_turn_off(dev, 0); 74 b43legacy_radio_turn_off(dev, 0);
70 } 75 }
71 } 76 }
72 mutex_unlock(&wl->mutex);
73}
74
75/* Called when the RFKILL toggled in software.
76 * This is called without locking. */
77static int b43legacy_rfkill_soft_set(void *data, bool blocked)
78{
79 struct b43legacy_wldev *dev = data;
80 struct b43legacy_wl *wl = dev->wl;
81 int ret = -EINVAL;
82 77
83 if (!wl->rfkill.registered) 78 if (brought_up) {
84 return -EINVAL; 79 ssb_device_disable(dev->dev, 0);
85 80 ssb_bus_may_powerdown(bus);
86 mutex_lock(&wl->mutex);
87 if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)
88 goto out_unlock;
89
90 if (!dev->radio_hw_enable)
91 goto out_unlock;
92
93 if (!blocked != dev->phy.radio_on) {
94 if (!blocked)
95 b43legacy_radio_turn_on(dev);
96 else
97 b43legacy_radio_turn_off(dev, 0);
98 } 81 }
99 ret = 0;
100 82
101out_unlock:
102 mutex_unlock(&wl->mutex); 83 mutex_unlock(&wl->mutex);
103 return ret;
104}
105
106const char *b43legacy_rfkill_led_name(struct b43legacy_wldev *dev)
107{
108 struct b43legacy_rfkill *rfk = &(dev->wl->rfkill);
109
110 if (!rfk->registered)
111 return NULL;
112 return rfkill_get_led_trigger_name(rfk->rfkill);
113} 84}
114
115static const struct rfkill_ops b43legacy_rfkill_ops = {
116 .set_block = b43legacy_rfkill_soft_set,
117 .poll = b43legacy_rfkill_poll,
118};
119
120void b43legacy_rfkill_init(struct b43legacy_wldev *dev)
121{
122 struct b43legacy_wl *wl = dev->wl;
123 struct b43legacy_rfkill *rfk = &(wl->rfkill);
124 int err;
125
126 rfk->registered = 0;
127
128 snprintf(rfk->name, sizeof(rfk->name),
129 "b43legacy-%s", wiphy_name(wl->hw->wiphy));
130 rfk->rfkill = rfkill_alloc(rfk->name,
131 dev->dev->dev,
132 RFKILL_TYPE_WLAN,
133 &b43legacy_rfkill_ops, dev);
134 if (!rfk->rfkill)
135 goto out_error;
136
137 err = rfkill_register(rfk->rfkill);
138 if (err)
139 goto err_free;
140
141 rfk->registered = 1;
142
143 return;
144 err_free:
145 rfkill_destroy(rfk->rfkill);
146 out_error:
147 rfk->registered = 0;
148 b43legacywarn(wl, "RF-kill button init failed\n");
149}
150
151void b43legacy_rfkill_exit(struct b43legacy_wldev *dev)
152{
153 struct b43legacy_rfkill *rfk = &(dev->wl->rfkill);
154
155 if (!rfk->registered)
156 return;
157 rfk->registered = 0;
158
159 rfkill_unregister(rfk->rfkill);
160 rfkill_destroy(rfk->rfkill);
161 rfk->rfkill = NULL;
162}
163
diff --git a/drivers/net/wireless/b43legacy/rfkill.h b/drivers/net/wireless/b43legacy/rfkill.h
index adffc503a6a1..75585571c544 100644
--- a/drivers/net/wireless/b43legacy/rfkill.h
+++ b/drivers/net/wireless/b43legacy/rfkill.h
@@ -1,55 +1,11 @@
1#ifndef B43legacy_RFKILL_H_ 1#ifndef B43legacy_RFKILL_H_
2#define B43legacy_RFKILL_H_ 2#define B43legacy_RFKILL_H_
3 3
4struct ieee80211_hw;
4struct b43legacy_wldev; 5struct b43legacy_wldev;
5 6
6#ifdef CONFIG_B43LEGACY_RFKILL 7void b43legacy_rfkill_poll(struct ieee80211_hw *hw);
7 8
8#include <linux/rfkill.h> 9bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev);
9
10
11
12struct b43legacy_rfkill {
13 /* The RFKILL subsystem data structure */
14 struct rfkill *rfkill;
15 /* Did initialization succeed? Used for freeing. */
16 bool registered;
17 /* The unique name of this rfkill switch */
18 char name[sizeof("b43legacy-phy4294967295")];
19};
20
21/* The init function returns void, because we are not interested
22 * in failing the b43 init process when rfkill init failed. */
23void b43legacy_rfkill_init(struct b43legacy_wldev *dev);
24void b43legacy_rfkill_exit(struct b43legacy_wldev *dev);
25
26const char *b43legacy_rfkill_led_name(struct b43legacy_wldev *dev);
27
28
29#else /* CONFIG_B43LEGACY_RFKILL */
30/* No RFKILL support. */
31
32struct b43legacy_rfkill {
33 /* empty */
34};
35
36static inline void b43legacy_rfkill_alloc(struct b43legacy_wldev *dev)
37{
38}
39static inline void b43legacy_rfkill_free(struct b43legacy_wldev *dev)
40{
41}
42static inline void b43legacy_rfkill_init(struct b43legacy_wldev *dev)
43{
44}
45static inline void b43legacy_rfkill_exit(struct b43legacy_wldev *dev)
46{
47}
48static inline char *b43legacy_rfkill_led_name(struct b43legacy_wldev *dev)
49{
50 return NULL;
51}
52
53#endif /* CONFIG_B43LEGACY_RFKILL */
54 10
55#endif /* B43legacy_RFKILL_H_ */ 11#endif /* B43legacy_RFKILL_H_ */