Commit 93bb7f3a authored by Larry Finger's avatar Larry Finger Committed by David S. Miller
Browse files

b43legacy: RF-kill support



This adds full support for the RFKILL button and the RFKILL LED trigger.

This is a port to b43legacy of a patch by Michael Buesch <mb@bu3sch.de>
for b43.

Signed-off-by: default avatarLarry <Finger&lt;Larry.Finger@lwfinger.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ba48f7bb
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -37,7 +37,13 @@ config B43LEGACY_PCICORE_AUTOSELECT
# LED support
config B43LEGACY_LEDS
	bool
	depends on MAC80211_LEDS
	depends on B43LEGACY && MAC80211_LEDS
	default y

# RFKILL support
config B43LEGACY_RFKILL
	bool
	depends on B43LEGACY && RFKILL
	default y

config B43LEGACY_DEBUG
+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ b43legacy-y += phy.o
b43legacy-y				+= radio.o
b43legacy-y				+= sysfs.o
b43legacy-y				+= xmit.o
# b43 RFKILL button support
b43legacy-$(CONFIG_B43LEGACY_RFKILL)	+= rfkill.o
# b43legacy LED support
b43legacy-$(CONFIG_B43LEGACY_LEDS)	+= leds.o
# b43legacy debugging
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include "debugfs.h"
#include "leds.h"
#include "rfkill.h"
#include "phy.h"


@@ -592,6 +593,9 @@ struct b43legacy_wl {
	u8 rng_initialized;
	char rng_name[30 + 1];

	/* The RF-kill button */
	struct b43legacy_rfkill rfkill;

	/* List of all wireless devices on this chip */
	struct list_head devlist;
	u8 nr_devs;
@@ -667,6 +671,7 @@ struct b43legacy_wldev {
	struct b43legacy_led led_tx;
	struct b43legacy_led led_rx;
	struct b43legacy_led led_assoc;
	struct b43legacy_led led_radio;

	/* Reason code of the last interrupt. */
	u32 irq_reason;
+6 −2
Original line number Diff line number Diff line
@@ -156,12 +156,16 @@ static void b43legacy_map_led(struct b43legacy_wldev *dev,
				 ieee80211_get_rx_led_name(hw),
				 led_index, activelow);
		break;
	/*FIXME: We need another trigger for the "radio-on" LEDs below.
	 *       Wiggle that somehow into the rfkill subsystem. */
	case B43legacy_LED_RADIO_ALL:
	case B43legacy_LED_RADIO_A:
	case B43legacy_LED_RADIO_B:
	case B43legacy_LED_MODE_BG:
		snprintf(name, sizeof(name),
			 "b43legacy-%s:radio", wiphy_name(hw->wiphy));
		b43legacy_register_led(dev, &dev->led_radio, name,
				 b43legacy_rfkill_led_name(dev),
				 led_index, activelow);
		break;
	case B43legacy_LED_WEIRD:
	case B43legacy_LED_ASSOC:
		snprintf(name, sizeof(name),
+11 −7
Original line number Diff line number Diff line
@@ -1993,7 +1993,7 @@ static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
/* This is the opposite of b43legacy_chip_init() */
static void b43legacy_chip_exit(struct b43legacy_wldev *dev)
{
	b43legacy_radio_turn_off(dev);
	b43legacy_radio_turn_off(dev, 1);
	b43legacy_leds_exit(dev);
	b43legacy_gpio_cleanup(dev);
	/* firmware is released later */
@@ -2106,7 +2106,7 @@ static int b43legacy_chip_init(struct b43legacy_wldev *dev)
	return err;

err_radio_off:
	b43legacy_radio_turn_off(dev);
	b43legacy_radio_turn_off(dev, 1);
err_leds_exit:
	b43legacy_leds_exit(dev);
	b43legacy_gpio_cleanup(dev);
@@ -2154,8 +2154,7 @@ static void b43legacy_periodic_every1sec(struct b43legacy_wldev *dev)
	radio_hw_enable = b43legacy_is_hw_radio_enabled(dev);
	if (unlikely(dev->radio_hw_enable != radio_hw_enable)) {
		dev->radio_hw_enable = radio_hw_enable;
		b43legacyinfo(dev->wl, "Radio hardware status changed to %s\n",
		       (radio_hw_enable) ? "enabled" : "disabled");
		b43legacy_rfkill_toggled(dev, radio_hw_enable);
	}
}

@@ -2647,7 +2646,7 @@ static int b43legacy_dev_config(struct ieee80211_hw *hw,
					      " physically off. Press the"
					      " button to turn it on.\n");
		} else {
			b43legacy_radio_turn_off(dev);
			b43legacy_radio_turn_off(dev, 0);
			b43legacyinfo(dev->wl, "Radio turned off by"
				      " software\n");
		}
@@ -3034,11 +3033,15 @@ static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev)
	cancel_work_sync(&dev->restart_work);
	mutex_lock(&wl->mutex);

	mutex_unlock(&dev->wl->mutex);
	b43legacy_rfkill_exit(dev);
	mutex_lock(&dev->wl->mutex);

	b43legacy_rng_exit(dev->wl);
	b43legacy_pio_free(dev);
	b43legacy_dma_free(dev);
	b43legacy_chip_exit(dev);
	b43legacy_radio_turn_off(dev);
	b43legacy_radio_turn_off(dev, 1);
	b43legacy_switch_analog(dev, 0);
	if (phy->dyn_tssi_tbl)
		kfree(phy->tssi2dbm);
@@ -3206,6 +3209,7 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev)
	memset(wl->mac_addr, 0, ETH_ALEN);
	b43legacy_upload_card_macaddress(dev);
	b43legacy_security_init(dev);
	b43legacy_rfkill_init(dev);
	b43legacy_rng_init(wl);

	b43legacy_set_status(dev, B43legacy_STAT_INITIALIZED);
@@ -3527,7 +3531,7 @@ static int b43legacy_wireless_core_attach(struct b43legacy_wldev *dev)
		wl->current_dev = dev;
	INIT_WORK(&dev->restart_work, b43legacy_chip_reset);

	b43legacy_radio_turn_off(dev);
	b43legacy_radio_turn_off(dev, 1);
	b43legacy_switch_analog(dev, 0);
	ssb_device_disable(dev->dev, 0);
	ssb_bus_may_powerdown(bus);
Loading