b43/legacy: port to cfg80211 rfkill
Johannes Berg
maintainerPATCH 1/1 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.
---
V1 - Original by Johannes.
V2 - Modified in testing by Larry.
The rfkill polling routine brings the interface back to the initialized state if it is found to be uninitialized. This way the rfkill switch may be interpreted. In addition, the radio LED is not turned on in the initialization routine unless the rfkill switch is on.
V3 - turn the device off again too
This is quite heavyweight and can probably be improved by not bringing up the PHY, radio, etc. just to poll the bit. We probably don't even need firmware, just MMIO accesses, but I can't test anything like that and this should work.
Please don't merge before anyone has tested it at least once though :)
b43/Kconfig | 7 --- b43/Makefile | 2 b43/b43.h | 3 - b43/leds.c | 7 +-- b43/main.c | 30 ++++---------- b43/main.h | 2 b43/phy_common.h | 2 b43/rfkill.c | 102 ++++------------------------------------------- b43/rfkill.h | 44 +------------------- b43legacy/Kconfig | 8 --- b43legacy/Makefile | 2 b43legacy/b43legacy.h | 3 - b43legacy/leds.c | 7 +-- b43legacy/main.c | 20 ++------- b43legacy/main.h | 2 drivers/net/wireless/b43/Kconfig | 7 - drivers/net/wireless/b43/Makefile | 2 drivers/net/wireless/b43/b43.h | 3 drivers/net/wireless/b43/leds.c | 7 + drivers/net/wireless/b43/main.c | 33 ++------ drivers/net/wireless/b43/main.h | 3 drivers/net/wireless/b43/phy_common.h | 2 drivers/net/wireless/b43/rfkill.c | 107 ++++----------------------- drivers/net/wireless/b43/rfkill.h | 44 +---------- drivers/net/wireless/b43legacy/Kconfig | 8 -- drivers/net/wireless/b43legacy/Makefile | 2 drivers/net/wireless/b43legacy/b43legacy.h | 3 drivers/net/wireless/b43legacy/leds.c | 7 + drivers/net/wireless/b43legacy/main.c | 23 +---- drivers/net/wireless/b43legacy/main.h | 3 drivers/net/wireless/b43legacy/rfkill.c | 112 ++++------------------------- drivers/net/wireless/b43legacy/rfkill.h | 50 ------------ 17 files changed, 72 insertions(+), 344 deletions(-)
drivers/net/wireless/b43/Kconfig +0 -7
@@ -98,13 +98,6 @@ config B43_LEDS depends on B43 && MAC80211_LEDS && (LEDS_CLASS = y || LEDS_CLASS = B43) default y -# This config option automatically enables b43 RFKILL support, -# if it's possible. -config B43_RFKILL - bool - depends on B43 && (RFKILL = y || RFKILL = B43) - default y - # This config option automatically enables b43 HW-RNG support, # if the HW-RNG core is enabled. config B43_HWRNG
drivers/net/wireless/b43/b43.h +0 -3
@@ -631,9 +631,6 @@ struct b43_wl {char rng_name[30 +1 ];#endif /* CONFIG_B43_HWRNG */ -/* The RF-kill button */ -struct b43_rfkill rfkill; -/* List of all wireless devices on this chip */ struct list_head devlist;u8 nr_devs;
drivers/net/wireless/b43/main.c +10 -23
@@ -284,8 +284,6 @@ static struct ieee80211_supported_band b .n_bitrates = b43_g_ratetable_size, }; -static void b43_wireless_core_exit (struct b43_wldev *dev); -static int b43_wireless_core_init (struct b43_wldev *dev);static void b43_wireless_core_stop (struct b43_wldev *dev);static int b43_wireless_core_start (struct b43_wldev *dev);
@@ -4070,7 +4068,7 @@ static void b43_set_pretbtt(struct b43_w/* Shutdown a wireless core */ /* Locking: wl->mutex */ -static void b43_wireless_core_exit (struct b43_wldev *dev) +void b43_wireless_core_exit (struct b43_wldev *dev) {u32 macctl;
@@ -4103,7 +4101,7 @@ static void b43_wireless_core_exit(struc }/* Initialize a wireless core */ -static int b43_wireless_core_init (struct b43_wldev *dev) +int b43_wireless_core_init (struct b43_wldev *dev) {struct b43_wl *wl = dev->wl;struct ssb_bus *bus = dev->dev->bus;
@@ -4298,7 +4296,6 @@ static int b43_op_start(struct ieee80211struct b43_wldev *dev = wl->current_dev;int did_init =0 ;int err =0 ; -bool do_rfkill_exit =0 ;/* Kill all old instance specific information to make sure * the card won't use it in the short timeframe between start
@@ -4312,18 +4309,12 @@ static int b43_op_start(struct ieee80211 wl->beacon1_uploaded =0 ; wl->beacon_templates_virgin =1 ; -/* First register RFkill. -* LEDs that are registered later depend on it. */ -b43_rfkill_init (dev); -mutex_lock (&wl->mutex);if (b43_status (dev) <B43_STAT_INITIALIZED ) { err =b43_wireless_core_init (dev); -if (err) { - do_rfkill_exit =1 ; +if (err) goto out_mutex_unlock; - } did_init =1 ; }
@@ -4332,17 +4323,16 @@ static int b43_op_start(struct ieee80211if (err) {if (did_init)b43_wireless_core_exit (dev); - do_rfkill_exit =1 ; goto out_mutex_unlock; } } +/* XXX: only do if device doesn't support rfkill irq */ +wiphy_rfkill_start_polling (hw->wiphy); + out_mutex_unlock:mutex_unlock (&wl->mutex); -if (do_rfkill_exit) -b43_rfkill_exit (dev); -return err; }
@@ -4351,7 +4341,6 @@ static void b43_op_stop(struct ieee80211struct b43_wl *wl =hw_to_b43_wl (hw);struct b43_wldev *dev = wl->current_dev; -b43_rfkill_exit (dev);cancel_work_sync (&(wl->beacon_update_trigger));mutex_lock (&wl->mutex);
@@ -4433,6 +4422,7 @@ static const struct ieee80211_ops b43_hw .sta_notify = b43_op_sta_notify, .sw_scan_start = b43_op_sw_scan_start_notifier, .sw_scan_complete = b43_op_sw_scan_complete_notifier, + .rfkill_poll = b43_rfkill_poll, };/* Hard-reset the chip. Do not call this directly.
@@ -4920,7 +4910,7 @@ static struct ssb_driver b43_ssb_driverstatic void b43_print_driverinfo (void ) {const char *feat_pci ="" , *feat_pcmcia ="" , *feat_nphy ="" , - *feat_leds ="" , *feat_rfkill ="" ; + *feat_leds ="" ;#ifdef CONFIG_B43_PCI_AUTOSELECT feat_pci ="P" ;
@@ -4934,14 +4924,11 @@ static void b43_print_driverinfo(void)#ifdef CONFIG_B43_LEDS feat_leds ="L" ;#endif -#ifdef CONFIG_B43_RFKILL - feat_rfkill ="R" ; -#endif printk (KERN_INFO "Broadcom 43xx driver loaded " -"[ Features: %s%s%s%s%s, Firmware-ID: " +"[ Features: %s%s%s%s, Firmware-ID: " B43_SUPPORTED_FIRMWARE_ID " ]\n" , feat_pci, feat_pcmcia, feat_nphy, - feat_leds, feat_rfkill); + feat_leds); }static int __init b43_init (void )
drivers/net/wireless/b43/rfkill.c +16 -91
141 lines not on this page · raw message
drivers/net/wireless/b43/rfkill.h +4 -40
53 lines not on this page · raw message
drivers/net/wireless/b43/Makefile +1 -1
@@ -13,7 +13,7 @@ b43-y += lo.o b43-y += wa.o b43-y += dma.o b43-$(CONFIG_B43_PIO) += pio.o -b43-$(CONFIG_B43_RFKILL) += rfkill.o +b43-y += rfkill.o b43-$(CONFIG_B43_LEDS) += leds.o b43-$(CONFIG_B43_PCMCIA) += pcmcia.o b43-$(CONFIG_B43_DEBUG) += debugfs.o
drivers/net/wireless/b43legacy/Kconfig +0 -8
@@ -42,14 +42,6 @@ config B43LEGACY_LEDS depends on B43LEGACY && MAC80211_LEDS && (LEDS_CLASS = y || LEDS_CLASS = B43LEGACY) default y -# RFKILL support -# This config option automatically enables b43legacy RFKILL support, -# if it's possible. -config B43LEGACY_RFKILL - bool - depends on B43LEGACY && (RFKILL = y || RFKILL = B43LEGACY) - default y - # This config option automatically enables b43 HW-RNG support, # if the HW-RNG core is enabled. config B43LEGACY_HWRNG
drivers/net/wireless/b43legacy/Makefile +1 -1
@@ -6,7 +6,7 @@ b43legacy-y += radio.o b43legacy-y += sysfs.o b43legacy-y += xmit.o # b43 RFKILL button support -b43legacy-$(CONFIG_B43LEGACY_RFKILL) += rfkill.o +b43legacy-y += rfkill.o # b43legacy LED support b43legacy-$(CONFIG_B43LEGACY_LEDS) += leds.o # b43legacy debugging
drivers/net/wireless/b43legacy/main.c +6 -17
@@ -158,8 +158,6 @@ static struct ieee80211_supported_band b .n_bitrates = b43legacy_g_ratetable_size, }; -static void b43legacy_wireless_core_exit (struct b43legacy_wldev *dev); -static int b43legacy_wireless_core_init (struct b43legacy_wldev *dev);static void b43legacy_wireless_core_stop (struct b43legacy_wldev *dev);static int b43legacy_wireless_core_start (struct b43legacy_wldev *dev);
@@ -3154,7 +3152,7 @@ static void b43legacy_set_pretbtt(struct/* Shutdown a wireless core */ /* Locking: wl->mutex */ -static void b43legacy_wireless_core_exit (struct b43legacy_wldev *dev) +void b43legacy_wireless_core_exit (struct b43legacy_wldev *dev) {struct b43legacy_phy *phy = &dev->phy;u32 macctl;
@@ -3230,7 +3228,7 @@ static void prepare_phy_data_for_init(st }/* Initialize a wireless core */ -static int b43legacy_wireless_core_init (struct b43legacy_wldev *dev) +int b43legacy_wireless_core_init (struct b43legacy_wldev *dev) {struct b43legacy_wl *wl = dev->wl;struct ssb_bus *bus = dev->dev->bus;
@@ -3431,11 +3429,6 @@ static int b43legacy_op_start(struct ieestruct b43legacy_wldev *dev = wl->current_dev;int did_init =0 ;int err =0 ; -bool do_rfkill_exit =0 ; - -/* First register RFkill. -* LEDs that are registered later depend on it. */ -b43legacy_rfkill_init (dev);/* Kill all old instance specific information to make sure * the card won't use it in the short timeframe between start
@@ -3451,10 +3444,8 @@ static int b43legacy_op_start(struct ieeif (b43legacy_status (dev) < B43legacy_STAT_INITIALIZED) { err =b43legacy_wireless_core_init (dev); -if (err) { - do_rfkill_exit =1 ; +if (err) goto out_mutex_unlock; - } did_init =1 ; }
@@ -3463,17 +3454,15 @@ static int b43legacy_op_start(struct ieeif (err) {if (did_init)b43legacy_wireless_core_exit (dev); - do_rfkill_exit =1 ; goto out_mutex_unlock; } } +wiphy_rfkill_start_polling (hw->wiphy); + out_mutex_unlock:mutex_unlock (&wl->mutex); -if (do_rfkill_exit) -b43legacy_rfkill_exit (dev); -return err; }
@@ -3482,7 +3471,6 @@ static void b43legacy_op_stop(struct ieestruct b43legacy_wl *wl =hw_to_b43legacy_wl (hw);struct b43legacy_wldev *dev = wl->current_dev; -b43legacy_rfkill_exit (dev);cancel_work_sync (&(wl->beacon_update_trigger));mutex_lock (&wl->mutex);
@@ -3518,6 +3506,7 @@ static const struct ieee80211_ops b43leg .start = b43legacy_op_start, .stop = b43legacy_op_stop, .set_tim = b43legacy_op_beacon_set_tim, + .rfkill_poll = b43legacy_rfkill_poll, };/* Hard-reset the chip. Do not call this directly.
drivers/net/wireless/b43legacy/rfkill.c +16 -96
148 lines not on this page · raw message
drivers/net/wireless/b43legacy/rfkill.h +3 -47
58 lines not on this page · raw message
drivers/net/wireless/b43legacy/b43legacy.h +0 -3
@@ -602,9 +602,6 @@ struct b43legacy_wl {char rng_name[30 +1 ];#endif -/* The RF-kill button */ -struct b43legacy_rfkill rfkill; -/* List of all wireless devices on this chip */ struct list_head devlist;u8 nr_devs;
drivers/net/wireless/b43/phy_common.h +1 -1
@@ -1,7 +1,7 @@#ifndef LINUX_B43_PHY_COMMON_H_ #define LINUX_B43_PHY_COMMON_H_ -#include <linux/rfkill.h> +#include <linux/types.h> struct b43_wldev ;
drivers/net/wireless/b43/leds.c +4 -3
@@ -28,6 +28,7 @@#include "b43.h" #include "leds.h" +#include "rfkill.h" static void b43_led_turn_on(struct b43_wldev *dev, u8 led_index,
@@ -164,10 +165,10 @@ static void b43_map_led(struct b43_wldevsnprintf (name,sizeof (name),"b43-%s::radio" ,wiphy_name (hw->wiphy));b43_register_led (dev, &dev->led_radio, name, -b43_rfkill_led_name (dev), +ieee80211_get_radio_led_name (hw), led_index, activelow); -/* Sync the RF-kill LED state with the switch state. */ -if (dev->radio_hw_enable) +/* Sync the RF-kill LED state with radio and switch states. */ +if (dev->phy.radio_on &&b43_is_hw_radio_enabled (dev))b43_led_turn_on (dev, led_index, activelow);break ;case B43_LED_WEIRD :
drivers/net/wireless/b43legacy/leds.c +4 -3
@@ -28,6 +28,7 @@#include "b43legacy.h" #include "leds.h" +#include "rfkill.h" static void b43legacy_led_turn_on(struct b43legacy_wldev *dev, u8 led_index,
@@ -164,10 +165,10 @@ static void b43legacy_map_led(struct b43snprintf (name,sizeof (name),"b43legacy-%s::radio" ,wiphy_name (hw->wiphy));b43legacy_register_led (dev, &dev->led_radio, name, -b43legacy_rfkill_led_name (dev), +ieee80211_get_radio_led_name (hw), led_index, activelow); -/* Sync the RF-kill LED state with the switch state. */ -if (dev->radio_hw_enable) +/* Sync the RF-kill LED state with radio and switch states. */ +if (dev->phy.radio_on &&b43legacy_is_hw_radio_enabled (dev))b43legacy_led_turn_on (dev, led_index, activelow);break ;case B43legacy_LED_WEIRD:
drivers/net/wireless/b43/main.h +3 -0
@@ -128,6 +128,9 @@ void b43_dummy_transmission(struct b43_wvoid b43_wireless_core_reset (struct b43_wldev *dev,u32 flags); +int b43_wireless_core_init (struct b43_wldev *dev); +void b43_wireless_core_exit (struct b43_wldev *dev); +void b43_controller_restart (struct b43_wldev *dev,const char *reason);#define B43_PS_ENABLED (1 << 0)/* Force enable hardware power saving */
drivers/net/wireless/b43legacy/main.h +3 -0
@@ -118,6 +118,9 @@ void b43legacy_dummy_transmission(structvoid b43legacy_wireless_core_reset (struct b43legacy_wldev *dev,u32 flags); +int b43legacy_wireless_core_init (struct b43legacy_wldev *dev); +void b43legacy_wireless_core_exit (struct b43legacy_wldev *dev); +void b43legacy_mac_suspend (struct b43legacy_wldev *dev);void b43legacy_mac_enable (struct b43legacy_wldev *dev);
Quoted 17 lines · Johannes Berg
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 <[email protected]>Signed-off-by Larry Finger <[email protected]>Cc Michael Buesch <[email protected]>---
V1 - Original by Johannes.
V2 - Modified in testing by Larry.
The rfkill polling routine brings the interface back to the initialized state if it is found to be uninitialized. This way the rfkill switch may be interpreted. In addition, the radio LED is not turned on in the initialization routine unless the rfkill switch is on.
V3 - turn the device off again too
Quoted 6 lines
This is quite heavyweight and can probably be improved by not bringing up the PHY, radio, etc. just to poll the bit. We probably don't even need firmware, just MMIO accesses, but I can't test anything like that and this should work.
Please don't merge before anyone has tested it at least once though :)
This one works, but so does the lightweight method proposed by Michael. It saves both time and power. With your permission, I would like to submit that one as V4 of the RFC/RFT (V2 of the patch).
Larry
Johannes Berg
maintainerQuoted 10 lines · Larry Finger
Quoted 6 lines
This is quite heavyweight and can probably be improved by not bringing up the PHY, radio, etc. just to poll the bit. We probably don't even need firmware, just MMIO accesses, but I can't test anything like that and this should work.
Please don't merge before anyone has tested it at least once though :)
This one works, but so does the lightweight method proposed by Michael. It saves both time and power. With your permission, I would like to submit that one as V4 of the RFC/RFT (V2 of the patch).
Certainly, please do, I appreciate it. I no longer have any devices easily available for testing and was pretty certain this version would work.
johannes