diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-06-02 07:01:37 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-06-03 14:06:13 -0400 |
commit | 19d337dff95cbf76edd3ad95c0cee2732c3e1ec5 (patch) | |
tree | 33326eeb09cb9664cc8427a5dc7cd2b08b5a57c3 /drivers/net/wireless/b43 | |
parent | 0f6399c4c525b518644a9b09f8d6fb125a418c4d (diff) |
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/b43')
-rw-r--r-- | drivers/net/wireless/b43/Kconfig | 2 | ||||
-rw-r--r-- | drivers/net/wireless/b43/leds.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/b43/main.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_a.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_common.c | 17 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_common.h | 4 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_g.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_lp.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/b43/rfkill.c | 123 | ||||
-rw-r--r-- | drivers/net/wireless/b43/rfkill.h | 5 |
11 files changed, 53 insertions, 116 deletions
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig index 21572e40b79d..07a99e3faf94 100644 --- a/drivers/net/wireless/b43/Kconfig +++ b/drivers/net/wireless/b43/Kconfig | |||
@@ -102,7 +102,7 @@ config B43_LEDS | |||
102 | # if it's possible. | 102 | # if it's possible. |
103 | config B43_RFKILL | 103 | config B43_RFKILL |
104 | bool | 104 | bool |
105 | depends on B43 && (RFKILL = y || RFKILL = B43) && RFKILL_INPUT && (INPUT_POLLDEV = y || INPUT_POLLDEV = B43) | 105 | depends on B43 && (RFKILL = y || RFKILL = B43) |
106 | default y | 106 | default y |
107 | 107 | ||
108 | # This config option automatically enables b43 HW-RNG support, | 108 | # This config option automatically enables b43 HW-RNG support, |
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c index 76f4c7bad8b8..9a498d3fc653 100644 --- a/drivers/net/wireless/b43/leds.c +++ b/drivers/net/wireless/b43/leds.c | |||
@@ -87,7 +87,7 @@ static void b43_led_brightness_set(struct led_classdev *led_dev, | |||
87 | } | 87 | } |
88 | 88 | ||
89 | static int b43_register_led(struct b43_wldev *dev, struct b43_led *led, | 89 | static int b43_register_led(struct b43_wldev *dev, struct b43_led *led, |
90 | const char *name, char *default_trigger, | 90 | const char *name, const char *default_trigger, |
91 | u8 led_index, bool activelow) | 91 | u8 led_index, bool activelow) |
92 | { | 92 | { |
93 | int err; | 93 | int err; |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index cb4a8712946a..1d3e40095ada 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -3470,7 +3470,7 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed) | |||
3470 | 3470 | ||
3471 | if (!!conf->radio_enabled != phy->radio_on) { | 3471 | if (!!conf->radio_enabled != phy->radio_on) { |
3472 | if (conf->radio_enabled) { | 3472 | if (conf->radio_enabled) { |
3473 | b43_software_rfkill(dev, RFKILL_STATE_UNBLOCKED); | 3473 | b43_software_rfkill(dev, false); |
3474 | b43info(dev->wl, "Radio turned on by software\n"); | 3474 | b43info(dev->wl, "Radio turned on by software\n"); |
3475 | if (!dev->radio_hw_enable) { | 3475 | if (!dev->radio_hw_enable) { |
3476 | b43info(dev->wl, "The hardware RF-kill button " | 3476 | b43info(dev->wl, "The hardware RF-kill button " |
@@ -3478,7 +3478,7 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed) | |||
3478 | "Press the button to turn it on.\n"); | 3478 | "Press the button to turn it on.\n"); |
3479 | } | 3479 | } |
3480 | } else { | 3480 | } else { |
3481 | b43_software_rfkill(dev, RFKILL_STATE_SOFT_BLOCKED); | 3481 | b43_software_rfkill(dev, true); |
3482 | b43info(dev->wl, "Radio turned off by software\n"); | 3482 | b43info(dev->wl, "Radio turned off by software\n"); |
3483 | } | 3483 | } |
3484 | } | 3484 | } |
diff --git a/drivers/net/wireless/b43/phy_a.c b/drivers/net/wireless/b43/phy_a.c index c836c077d51d..816e028a2620 100644 --- a/drivers/net/wireless/b43/phy_a.c +++ b/drivers/net/wireless/b43/phy_a.c | |||
@@ -480,11 +480,11 @@ static bool b43_aphy_op_supports_hwpctl(struct b43_wldev *dev) | |||
480 | } | 480 | } |
481 | 481 | ||
482 | static void b43_aphy_op_software_rfkill(struct b43_wldev *dev, | 482 | static void b43_aphy_op_software_rfkill(struct b43_wldev *dev, |
483 | enum rfkill_state state) | 483 | bool blocked) |
484 | { | 484 | { |
485 | struct b43_phy *phy = &dev->phy; | 485 | struct b43_phy *phy = &dev->phy; |
486 | 486 | ||
487 | if (state == RFKILL_STATE_UNBLOCKED) { | 487 | if (!blocked) { |
488 | if (phy->radio_on) | 488 | if (phy->radio_on) |
489 | return; | 489 | return; |
490 | b43_radio_write16(dev, 0x0004, 0x00C0); | 490 | b43_radio_write16(dev, 0x0004, 0x00C0); |
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c index e176b6e0d9cf..6d241622210e 100644 --- a/drivers/net/wireless/b43/phy_common.c +++ b/drivers/net/wireless/b43/phy_common.c | |||
@@ -84,7 +84,7 @@ int b43_phy_init(struct b43_wldev *dev) | |||
84 | 84 | ||
85 | phy->channel = ops->get_default_chan(dev); | 85 | phy->channel = ops->get_default_chan(dev); |
86 | 86 | ||
87 | ops->software_rfkill(dev, RFKILL_STATE_UNBLOCKED); | 87 | ops->software_rfkill(dev, false); |
88 | err = ops->init(dev); | 88 | err = ops->init(dev); |
89 | if (err) { | 89 | if (err) { |
90 | b43err(dev->wl, "PHY init failed\n"); | 90 | b43err(dev->wl, "PHY init failed\n"); |
@@ -104,7 +104,7 @@ err_phy_exit: | |||
104 | if (ops->exit) | 104 | if (ops->exit) |
105 | ops->exit(dev); | 105 | ops->exit(dev); |
106 | err_block_rf: | 106 | err_block_rf: |
107 | ops->software_rfkill(dev, RFKILL_STATE_SOFT_BLOCKED); | 107 | ops->software_rfkill(dev, true); |
108 | 108 | ||
109 | return err; | 109 | return err; |
110 | } | 110 | } |
@@ -113,7 +113,7 @@ void b43_phy_exit(struct b43_wldev *dev) | |||
113 | { | 113 | { |
114 | const struct b43_phy_operations *ops = dev->phy.ops; | 114 | const struct b43_phy_operations *ops = dev->phy.ops; |
115 | 115 | ||
116 | ops->software_rfkill(dev, RFKILL_STATE_SOFT_BLOCKED); | 116 | ops->software_rfkill(dev, true); |
117 | if (ops->exit) | 117 | if (ops->exit) |
118 | ops->exit(dev); | 118 | ops->exit(dev); |
119 | } | 119 | } |
@@ -295,18 +295,13 @@ err_restore_cookie: | |||
295 | return err; | 295 | return err; |
296 | } | 296 | } |
297 | 297 | ||
298 | void b43_software_rfkill(struct b43_wldev *dev, enum rfkill_state state) | 298 | void b43_software_rfkill(struct b43_wldev *dev, bool blocked) |
299 | { | 299 | { |
300 | struct b43_phy *phy = &dev->phy; | 300 | struct b43_phy *phy = &dev->phy; |
301 | 301 | ||
302 | if (state == RFKILL_STATE_HARD_BLOCKED) { | ||
303 | /* We cannot hardware-block the device */ | ||
304 | state = RFKILL_STATE_SOFT_BLOCKED; | ||
305 | } | ||
306 | |||
307 | b43_mac_suspend(dev); | 302 | b43_mac_suspend(dev); |
308 | phy->ops->software_rfkill(dev, state); | 303 | phy->ops->software_rfkill(dev, blocked); |
309 | phy->radio_on = (state == RFKILL_STATE_UNBLOCKED); | 304 | phy->radio_on = !blocked; |
310 | b43_mac_enable(dev); | 305 | b43_mac_enable(dev); |
311 | } | 306 | } |
312 | 307 | ||
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h index b2d99101947b..f4c2d79cbc89 100644 --- a/drivers/net/wireless/b43/phy_common.h +++ b/drivers/net/wireless/b43/phy_common.h | |||
@@ -159,7 +159,7 @@ struct b43_phy_operations { | |||
159 | 159 | ||
160 | /* Radio */ | 160 | /* Radio */ |
161 | bool (*supports_hwpctl)(struct b43_wldev *dev); | 161 | bool (*supports_hwpctl)(struct b43_wldev *dev); |
162 | void (*software_rfkill)(struct b43_wldev *dev, enum rfkill_state state); | 162 | void (*software_rfkill)(struct b43_wldev *dev, bool blocked); |
163 | void (*switch_analog)(struct b43_wldev *dev, bool on); | 163 | void (*switch_analog)(struct b43_wldev *dev, bool on); |
164 | int (*switch_channel)(struct b43_wldev *dev, unsigned int new_channel); | 164 | int (*switch_channel)(struct b43_wldev *dev, unsigned int new_channel); |
165 | unsigned int (*get_default_chan)(struct b43_wldev *dev); | 165 | unsigned int (*get_default_chan)(struct b43_wldev *dev); |
@@ -364,7 +364,7 @@ int b43_switch_channel(struct b43_wldev *dev, unsigned int new_channel); | |||
364 | /** | 364 | /** |
365 | * b43_software_rfkill - Turn the radio ON or OFF in software. | 365 | * b43_software_rfkill - Turn the radio ON or OFF in software. |
366 | */ | 366 | */ |
367 | void b43_software_rfkill(struct b43_wldev *dev, enum rfkill_state state); | 367 | void b43_software_rfkill(struct b43_wldev *dev, bool blocked); |
368 | 368 | ||
369 | /** | 369 | /** |
370 | * b43_phy_txpower_check - Check TX power output. | 370 | * b43_phy_txpower_check - Check TX power output. |
diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c index e7b98f013b0f..5300232449f6 100644 --- a/drivers/net/wireless/b43/phy_g.c +++ b/drivers/net/wireless/b43/phy_g.c | |||
@@ -2592,7 +2592,7 @@ static bool b43_gphy_op_supports_hwpctl(struct b43_wldev *dev) | |||
2592 | } | 2592 | } |
2593 | 2593 | ||
2594 | static void b43_gphy_op_software_rfkill(struct b43_wldev *dev, | 2594 | static void b43_gphy_op_software_rfkill(struct b43_wldev *dev, |
2595 | enum rfkill_state state) | 2595 | bool blocked) |
2596 | { | 2596 | { |
2597 | struct b43_phy *phy = &dev->phy; | 2597 | struct b43_phy *phy = &dev->phy; |
2598 | struct b43_phy_g *gphy = phy->g; | 2598 | struct b43_phy_g *gphy = phy->g; |
@@ -2600,7 +2600,7 @@ static void b43_gphy_op_software_rfkill(struct b43_wldev *dev, | |||
2600 | 2600 | ||
2601 | might_sleep(); | 2601 | might_sleep(); |
2602 | 2602 | ||
2603 | if (state == RFKILL_STATE_UNBLOCKED) { | 2603 | if (!blocked) { |
2604 | /* Turn radio ON */ | 2604 | /* Turn radio ON */ |
2605 | if (phy->radio_on) | 2605 | if (phy->radio_on) |
2606 | return; | 2606 | return; |
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c index 58e319d6b1ed..ea0d3a3a6a64 100644 --- a/drivers/net/wireless/b43/phy_lp.c +++ b/drivers/net/wireless/b43/phy_lp.c | |||
@@ -488,7 +488,7 @@ static void b43_lpphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value) | |||
488 | } | 488 | } |
489 | 489 | ||
490 | static void b43_lpphy_op_software_rfkill(struct b43_wldev *dev, | 490 | static void b43_lpphy_op_software_rfkill(struct b43_wldev *dev, |
491 | enum rfkill_state state) | 491 | bool blocked) |
492 | { | 492 | { |
493 | //TODO | 493 | //TODO |
494 | } | 494 | } |
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 8bcfda5f3f07..be7b5604947b 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
@@ -579,7 +579,7 @@ static void b43_nphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value) | |||
579 | } | 579 | } |
580 | 580 | ||
581 | static void b43_nphy_op_software_rfkill(struct b43_wldev *dev, | 581 | static void b43_nphy_op_software_rfkill(struct b43_wldev *dev, |
582 | enum rfkill_state state) | 582 | bool blocked) |
583 | {//TODO | 583 | {//TODO |
584 | } | 584 | } |
585 | 585 | ||
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c index 9e1d00bc24d3..96047843cd56 100644 --- a/drivers/net/wireless/b43/rfkill.c +++ b/drivers/net/wireless/b43/rfkill.c | |||
@@ -45,12 +45,11 @@ static bool b43_is_hw_radio_enabled(struct b43_wldev *dev) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | /* The poll callback for the hardware button. */ | 47 | /* The poll callback for the hardware button. */ |
48 | static void b43_rfkill_poll(struct input_polled_dev *poll_dev) | 48 | static void b43_rfkill_poll(struct rfkill *rfkill, void *data) |
49 | { | 49 | { |
50 | struct b43_wldev *dev = poll_dev->private; | 50 | struct b43_wldev *dev = data; |
51 | struct b43_wl *wl = dev->wl; | 51 | struct b43_wl *wl = dev->wl; |
52 | bool enabled; | 52 | bool enabled; |
53 | bool report_change = 0; | ||
54 | 53 | ||
55 | mutex_lock(&wl->mutex); | 54 | mutex_lock(&wl->mutex); |
56 | if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) { | 55 | if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) { |
@@ -60,68 +59,55 @@ static void b43_rfkill_poll(struct input_polled_dev *poll_dev) | |||
60 | enabled = b43_is_hw_radio_enabled(dev); | 59 | enabled = b43_is_hw_radio_enabled(dev); |
61 | if (unlikely(enabled != dev->radio_hw_enable)) { | 60 | if (unlikely(enabled != dev->radio_hw_enable)) { |
62 | dev->radio_hw_enable = enabled; | 61 | dev->radio_hw_enable = enabled; |
63 | report_change = 1; | ||
64 | b43info(wl, "Radio hardware status changed to %s\n", | 62 | b43info(wl, "Radio hardware status changed to %s\n", |
65 | enabled ? "ENABLED" : "DISABLED"); | 63 | enabled ? "ENABLED" : "DISABLED"); |
64 | enabled = !rfkill_set_hw_state(rfkill, !enabled); | ||
65 | if (enabled != dev->phy.radio_on) | ||
66 | b43_software_rfkill(dev, !enabled); | ||
66 | } | 67 | } |
67 | mutex_unlock(&wl->mutex); | 68 | mutex_unlock(&wl->mutex); |
68 | |||
69 | /* send the radio switch event to the system - note both a key press | ||
70 | * and a release are required */ | ||
71 | if (unlikely(report_change)) { | ||
72 | input_report_key(poll_dev->input, KEY_WLAN, 1); | ||
73 | input_report_key(poll_dev->input, KEY_WLAN, 0); | ||
74 | } | ||
75 | } | 69 | } |
76 | 70 | ||
77 | /* Called when the RFKILL toggled in software. */ | 71 | /* Called when the RFKILL toggled in software. */ |
78 | static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state) | 72 | static int b43_rfkill_soft_set(void *data, bool blocked) |
79 | { | 73 | { |
80 | struct b43_wldev *dev = data; | 74 | struct b43_wldev *dev = data; |
81 | struct b43_wl *wl = dev->wl; | 75 | struct b43_wl *wl = dev->wl; |
82 | int err = -EBUSY; | 76 | int err = -EINVAL; |
83 | 77 | ||
84 | if (!wl->rfkill.registered) | 78 | if (WARN_ON(!wl->rfkill.registered)) |
85 | return 0; | 79 | return -EINVAL; |
86 | 80 | ||
87 | mutex_lock(&wl->mutex); | 81 | mutex_lock(&wl->mutex); |
82 | |||
88 | if (b43_status(dev) < B43_STAT_INITIALIZED) | 83 | if (b43_status(dev) < B43_STAT_INITIALIZED) |
89 | goto out_unlock; | 84 | goto out_unlock; |
85 | |||
86 | if (!dev->radio_hw_enable) | ||
87 | goto out_unlock; | ||
88 | |||
89 | if (!blocked != dev->phy.radio_on) | ||
90 | b43_software_rfkill(dev, blocked); | ||
90 | err = 0; | 91 | err = 0; |
91 | switch (state) { | ||
92 | case RFKILL_STATE_UNBLOCKED: | ||
93 | if (!dev->radio_hw_enable) { | ||
94 | /* No luck. We can't toggle the hardware RF-kill | ||
95 | * button from software. */ | ||
96 | err = -EBUSY; | ||
97 | goto out_unlock; | ||
98 | } | ||
99 | if (!dev->phy.radio_on) | ||
100 | b43_software_rfkill(dev, state); | ||
101 | break; | ||
102 | case RFKILL_STATE_SOFT_BLOCKED: | ||
103 | if (dev->phy.radio_on) | ||
104 | b43_software_rfkill(dev, state); | ||
105 | break; | ||
106 | default: | ||
107 | b43warn(wl, "Received unexpected rfkill state %d.\n", state); | ||
108 | break; | ||
109 | } | ||
110 | out_unlock: | 92 | out_unlock: |
111 | mutex_unlock(&wl->mutex); | 93 | mutex_unlock(&wl->mutex); |
112 | |||
113 | return err; | 94 | return err; |
114 | } | 95 | } |
115 | 96 | ||
116 | char *b43_rfkill_led_name(struct b43_wldev *dev) | 97 | const char *b43_rfkill_led_name(struct b43_wldev *dev) |
117 | { | 98 | { |
118 | struct b43_rfkill *rfk = &(dev->wl->rfkill); | 99 | struct b43_rfkill *rfk = &(dev->wl->rfkill); |
119 | 100 | ||
120 | if (!rfk->registered) | 101 | if (!rfk->registered) |
121 | return NULL; | 102 | return NULL; |
122 | return rfkill_get_led_name(rfk->rfkill); | 103 | return rfkill_get_led_trigger_name(rfk->rfkill); |
123 | } | 104 | } |
124 | 105 | ||
106 | static const struct rfkill_ops b43_rfkill_ops = { | ||
107 | .set_block = b43_rfkill_soft_set, | ||
108 | .poll = b43_rfkill_poll, | ||
109 | }; | ||
110 | |||
125 | void b43_rfkill_init(struct b43_wldev *dev) | 111 | void b43_rfkill_init(struct b43_wldev *dev) |
126 | { | 112 | { |
127 | struct b43_wl *wl = dev->wl; | 113 | struct b43_wl *wl = dev->wl; |
@@ -130,65 +116,26 @@ void b43_rfkill_init(struct b43_wldev *dev) | |||
130 | 116 | ||
131 | rfk->registered = 0; | 117 | rfk->registered = 0; |
132 | 118 | ||
133 | rfk->rfkill = rfkill_allocate(dev->dev->dev, RFKILL_TYPE_WLAN); | ||
134 | if (!rfk->rfkill) | ||
135 | goto out_error; | ||
136 | snprintf(rfk->name, sizeof(rfk->name), | 119 | snprintf(rfk->name, sizeof(rfk->name), |
137 | "b43-%s", wiphy_name(wl->hw->wiphy)); | 120 | "b43-%s", wiphy_name(wl->hw->wiphy)); |
138 | rfk->rfkill->name = rfk->name; | ||
139 | rfk->rfkill->state = RFKILL_STATE_UNBLOCKED; | ||
140 | rfk->rfkill->data = dev; | ||
141 | rfk->rfkill->toggle_radio = b43_rfkill_soft_toggle; | ||
142 | |||
143 | rfk->poll_dev = input_allocate_polled_device(); | ||
144 | if (!rfk->poll_dev) { | ||
145 | rfkill_free(rfk->rfkill); | ||
146 | goto err_freed_rfk; | ||
147 | } | ||
148 | |||
149 | rfk->poll_dev->private = dev; | ||
150 | rfk->poll_dev->poll = b43_rfkill_poll; | ||
151 | rfk->poll_dev->poll_interval = 1000; /* msecs */ | ||
152 | 121 | ||
153 | rfk->poll_dev->input->name = rfk->name; | 122 | rfk->rfkill = rfkill_alloc(rfk->name, |
154 | rfk->poll_dev->input->id.bustype = BUS_HOST; | 123 | dev->dev->dev, |
155 | rfk->poll_dev->input->id.vendor = dev->dev->bus->boardinfo.vendor; | 124 | RFKILL_TYPE_WLAN, |
156 | rfk->poll_dev->input->evbit[0] = BIT(EV_KEY); | 125 | &b43_rfkill_ops, dev); |
157 | set_bit(KEY_WLAN, rfk->poll_dev->input->keybit); | 126 | if (!rfk->rfkill) |
127 | goto out_error; | ||
158 | 128 | ||
159 | err = rfkill_register(rfk->rfkill); | 129 | err = rfkill_register(rfk->rfkill); |
160 | if (err) | 130 | if (err) |
161 | goto err_free_polldev; | 131 | goto err_free; |
162 | |||
163 | #ifdef CONFIG_RFKILL_INPUT_MODULE | ||
164 | /* B43 RF-kill isn't useful without the rfkill-input subsystem. | ||
165 | * Try to load the module. */ | ||
166 | err = request_module("rfkill-input"); | ||
167 | if (err) | ||
168 | b43warn(wl, "Failed to load the rfkill-input module. " | ||
169 | "The built-in radio LED will not work.\n"); | ||
170 | #endif /* CONFIG_RFKILL_INPUT */ | ||
171 | |||
172 | #if !defined(CONFIG_RFKILL_INPUT) && !defined(CONFIG_RFKILL_INPUT_MODULE) | ||
173 | b43warn(wl, "The rfkill-input subsystem is not available. " | ||
174 | "The built-in radio LED will not work.\n"); | ||
175 | #endif | ||
176 | |||
177 | err = input_register_polled_device(rfk->poll_dev); | ||
178 | if (err) | ||
179 | goto err_unreg_rfk; | ||
180 | 132 | ||
181 | rfk->registered = 1; | 133 | rfk->registered = 1; |
182 | 134 | ||
183 | return; | 135 | return; |
184 | err_unreg_rfk: | 136 | err_free: |
185 | rfkill_unregister(rfk->rfkill); | 137 | rfkill_destroy(rfk->rfkill); |
186 | err_free_polldev: | 138 | out_error: |
187 | input_free_polled_device(rfk->poll_dev); | ||
188 | rfk->poll_dev = NULL; | ||
189 | err_freed_rfk: | ||
190 | rfk->rfkill = NULL; | ||
191 | out_error: | ||
192 | rfk->registered = 0; | 139 | rfk->registered = 0; |
193 | b43warn(wl, "RF-kill button init failed\n"); | 140 | b43warn(wl, "RF-kill button init failed\n"); |
194 | } | 141 | } |
@@ -201,9 +148,7 @@ void b43_rfkill_exit(struct b43_wldev *dev) | |||
201 | return; | 148 | return; |
202 | rfk->registered = 0; | 149 | rfk->registered = 0; |
203 | 150 | ||
204 | input_unregister_polled_device(rfk->poll_dev); | ||
205 | rfkill_unregister(rfk->rfkill); | 151 | rfkill_unregister(rfk->rfkill); |
206 | input_free_polled_device(rfk->poll_dev); | 152 | rfkill_destroy(rfk->rfkill); |
207 | rfk->poll_dev = NULL; | ||
208 | rfk->rfkill = NULL; | 153 | rfk->rfkill = NULL; |
209 | } | 154 | } |
diff --git a/drivers/net/wireless/b43/rfkill.h b/drivers/net/wireless/b43/rfkill.h index adacf936d815..da497e01bbb1 100644 --- a/drivers/net/wireless/b43/rfkill.h +++ b/drivers/net/wireless/b43/rfkill.h | |||
@@ -7,14 +7,11 @@ struct b43_wldev; | |||
7 | #ifdef CONFIG_B43_RFKILL | 7 | #ifdef CONFIG_B43_RFKILL |
8 | 8 | ||
9 | #include <linux/rfkill.h> | 9 | #include <linux/rfkill.h> |
10 | #include <linux/input-polldev.h> | ||
11 | 10 | ||
12 | 11 | ||
13 | struct b43_rfkill { | 12 | struct b43_rfkill { |
14 | /* The RFKILL subsystem data structure */ | 13 | /* The RFKILL subsystem data structure */ |
15 | struct rfkill *rfkill; | 14 | struct rfkill *rfkill; |
16 | /* The poll device for the RFKILL input button */ | ||
17 | struct input_polled_dev *poll_dev; | ||
18 | /* Did initialization succeed? Used for freeing. */ | 15 | /* Did initialization succeed? Used for freeing. */ |
19 | bool registered; | 16 | bool registered; |
20 | /* The unique name of this rfkill switch */ | 17 | /* The unique name of this rfkill switch */ |
@@ -26,7 +23,7 @@ struct b43_rfkill { | |||
26 | void b43_rfkill_init(struct b43_wldev *dev); | 23 | void b43_rfkill_init(struct b43_wldev *dev); |
27 | void b43_rfkill_exit(struct b43_wldev *dev); | 24 | void b43_rfkill_exit(struct b43_wldev *dev); |
28 | 25 | ||
29 | char * b43_rfkill_led_name(struct b43_wldev *dev); | 26 | const char *b43_rfkill_led_name(struct b43_wldev *dev); |
30 | 27 | ||
31 | 28 | ||
32 | #else /* CONFIG_B43_RFKILL */ | 29 | #else /* CONFIG_B43_RFKILL */ |