aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2007-12-22 15:54:20 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:14 -0500
commit9db1f6d725921c413cc344beda5e7e7d011b02e7 (patch)
treed3da80ab61fce4074c18f88d31c75e900afb7c22 /drivers/net/wireless
parente861b98d5e1be769ca6483b6df97149b956ea834 (diff)
b43: Only select allowed TX and RX antennas
This fixes antenna selection in b43. It adds a sanity check for the antenna numbers we get from mac80211. This patch depends on ssb: Fix extraction of values from SPROM Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/b43/main.c42
-rw-r--r--drivers/net/wireless/b43/main.h3
-rw-r--r--drivers/net/wireless/b43/xmit.c9
3 files changed, 42 insertions, 12 deletions
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 68bbe8eafd6..f4c14272332 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2692,8 +2692,36 @@ static int b43_switch_phymode(struct b43_wl *wl, unsigned int new_mode)
2692 return err; 2692 return err;
2693} 2693}
2694 2694
2695static int b43_antenna_from_ieee80211(u8 antenna) 2695/* Check if the use of the antenna that ieee80211 told us to
2696 * use is possible. This will fall back to DEFAULT.
2697 * "antenna_nr" is the antenna identifier we got from ieee80211. */
2698u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
2699 u8 antenna_nr)
2696{ 2700{
2701 u8 antenna_mask;
2702
2703 if (antenna_nr == 0) {
2704 /* Zero means "use default antenna". That's always OK. */
2705 return 0;
2706 }
2707
2708 /* Get the mask of available antennas. */
2709 if (dev->phy.gmode)
2710 antenna_mask = dev->dev->bus->sprom.ant_available_bg;
2711 else
2712 antenna_mask = dev->dev->bus->sprom.ant_available_a;
2713
2714 if (!(antenna_mask & (1 << (antenna_nr - 1)))) {
2715 /* This antenna is not available. Fall back to default. */
2716 return 0;
2717 }
2718
2719 return antenna_nr;
2720}
2721
2722static int b43_antenna_from_ieee80211(struct b43_wldev *dev, u8 antenna)
2723{
2724 antenna = b43_ieee80211_antenna_sanitize(dev, antenna);
2697 switch (antenna) { 2725 switch (antenna) {
2698 case 0: /* default/diversity */ 2726 case 0: /* default/diversity */
2699 return B43_ANTENNA_DEFAULT; 2727 return B43_ANTENNA_DEFAULT;
@@ -2713,14 +2741,10 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
2713 struct b43_phy *phy; 2741 struct b43_phy *phy;
2714 unsigned long flags; 2742 unsigned long flags;
2715 unsigned int new_phymode = 0xFFFF; 2743 unsigned int new_phymode = 0xFFFF;
2716 int antenna_tx; 2744 int antenna;
2717 int antenna_rx;
2718 int err = 0; 2745 int err = 0;
2719 u32 savedirqs; 2746 u32 savedirqs;
2720 2747
2721 antenna_tx = b43_antenna_from_ieee80211(conf->antenna_sel_tx);
2722 antenna_rx = b43_antenna_from_ieee80211(conf->antenna_sel_rx);
2723
2724 mutex_lock(&wl->mutex); 2748 mutex_lock(&wl->mutex);
2725 2749
2726 /* Switch the PHY mode (if necessary). */ 2750 /* Switch the PHY mode (if necessary). */
@@ -2781,8 +2805,10 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
2781 } 2805 }
2782 2806
2783 /* Antennas for RX and management frame TX. */ 2807 /* Antennas for RX and management frame TX. */
2784 b43_mgmtframe_txantenna(dev, antenna_tx); 2808 antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_tx);
2785 b43_set_rx_antenna(dev, antenna_rx); 2809 b43_mgmtframe_txantenna(dev, antenna);
2810 antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_rx);
2811 b43_set_rx_antenna(dev, antenna);
2786 2812
2787 /* Update templates for AP mode. */ 2813 /* Update templates for AP mode. */
2788 if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP)) 2814 if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP))
diff --git a/drivers/net/wireless/b43/main.h b/drivers/net/wireless/b43/main.h
index a8503ef4ebc..2d52d9de930 100644
--- a/drivers/net/wireless/b43/main.h
+++ b/drivers/net/wireless/b43/main.h
@@ -84,6 +84,9 @@ static inline int b43_is_ofdm_rate(int rate)
84 return !b43_is_cck_rate(rate); 84 return !b43_is_cck_rate(rate);
85} 85}
86 86
87u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
88 u8 antenna_nr);
89
87void b43_tsf_read(struct b43_wldev *dev, u64 * tsf); 90void b43_tsf_read(struct b43_wldev *dev, u64 * tsf);
88void b43_tsf_write(struct b43_wldev *dev, u64 tsf); 91void b43_tsf_write(struct b43_wldev *dev, u64 tsf);
89 92
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index e60e54d59ab..3d312768588 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -270,14 +270,15 @@ static void generate_txhdr_fw4(struct b43_wldev *dev,
270 phy_ctl |= B43_TX4_PHY_OFDM; 270 phy_ctl |= B43_TX4_PHY_OFDM;
271 if (dev->short_preamble) 271 if (dev->short_preamble)
272 phy_ctl |= B43_TX4_PHY_SHORTPRMBL; 272 phy_ctl |= B43_TX4_PHY_SHORTPRMBL;
273 switch (txctl->antenna_sel_tx) { 273
274 case 0: 274 switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) {
275 case 0: /* Default */
275 phy_ctl |= B43_TX4_PHY_ANTLAST; 276 phy_ctl |= B43_TX4_PHY_ANTLAST;
276 break; 277 break;
277 case 1: 278 case 1: /* Antenna 0 */
278 phy_ctl |= B43_TX4_PHY_ANT0; 279 phy_ctl |= B43_TX4_PHY_ANT0;
279 break; 280 break;
280 case 2: 281 case 2: /* Antenna 1 */
281 phy_ctl |= B43_TX4_PHY_ANT1; 282 phy_ctl |= B43_TX4_PHY_ANT1;
282 break; 283 break;
283 default: 284 default: