Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9db1f6d725921c413cc344beda5e7e7d011b02e7
Commit:     9db1f6d725921c413cc344beda5e7e7d011b02e7
Parent:     e861b98d5e1be769ca6483b6df97149b956ea834
Author:     Michael Buesch <[EMAIL PROTECTED]>
AuthorDate: Sat Dec 22 21:54:20 2007 +0100
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 15:09:14 2008 -0800

    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 <[EMAIL PROTECTED]>
    Signed-off-by: John W. Linville <[EMAIL PROTECTED]>
---
 drivers/net/wireless/b43/main.c |   42 +++++++++++++++++++++++++++++++-------
 drivers/net/wireless/b43/main.h |    3 ++
 drivers/net/wireless/b43/xmit.c |    9 ++++---
 3 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 68bbe8e..f4c1427 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)
        return err;
 }
 
-static int b43_antenna_from_ieee80211(u8 antenna)
+/* Check if the use of the antenna that ieee80211 told us to
+ * use is possible. This will fall back to DEFAULT.
+ * "antenna_nr" is the antenna identifier we got from ieee80211. */
+u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
+                                 u8 antenna_nr)
 {
+       u8 antenna_mask;
+
+       if (antenna_nr == 0) {
+               /* Zero means "use default antenna". That's always OK. */
+               return 0;
+       }
+
+       /* Get the mask of available antennas. */
+       if (dev->phy.gmode)
+               antenna_mask = dev->dev->bus->sprom.ant_available_bg;
+       else
+               antenna_mask = dev->dev->bus->sprom.ant_available_a;
+
+       if (!(antenna_mask & (1 << (antenna_nr - 1)))) {
+               /* This antenna is not available. Fall back to default. */
+               return 0;
+       }
+
+       return antenna_nr;
+}
+
+static int b43_antenna_from_ieee80211(struct b43_wldev *dev, u8 antenna)
+{
+       antenna = b43_ieee80211_antenna_sanitize(dev, antenna);
        switch (antenna) {
        case 0:         /* default/diversity */
                return B43_ANTENNA_DEFAULT;
@@ -2713,14 +2741,10 @@ static int b43_op_config(struct ieee80211_hw *hw, 
struct ieee80211_conf *conf)
        struct b43_phy *phy;
        unsigned long flags;
        unsigned int new_phymode = 0xFFFF;
-       int antenna_tx;
-       int antenna_rx;
+       int antenna;
        int err = 0;
        u32 savedirqs;
 
-       antenna_tx = b43_antenna_from_ieee80211(conf->antenna_sel_tx);
-       antenna_rx = b43_antenna_from_ieee80211(conf->antenna_sel_rx);
-
        mutex_lock(&wl->mutex);
 
        /* Switch the PHY mode (if necessary). */
@@ -2781,8 +2805,10 @@ static int b43_op_config(struct ieee80211_hw *hw, struct 
ieee80211_conf *conf)
        }
 
        /* Antennas for RX and management frame TX. */
-       b43_mgmtframe_txantenna(dev, antenna_tx);
-       b43_set_rx_antenna(dev, antenna_rx);
+       antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_tx);
+       b43_mgmtframe_txantenna(dev, antenna);
+       antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_rx);
+       b43_set_rx_antenna(dev, antenna);
 
        /* Update templates for AP mode. */
        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 a8503ef..2d52d9d 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)
        return !b43_is_cck_rate(rate);
 }
 
+u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
+                                 u8 antenna_nr);
+
 void b43_tsf_read(struct b43_wldev *dev, u64 * tsf);
 void b43_tsf_write(struct b43_wldev *dev, u64 tsf);
 
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index e60e54d..3d31276 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,
                phy_ctl |= B43_TX4_PHY_OFDM;
        if (dev->short_preamble)
                phy_ctl |= B43_TX4_PHY_SHORTPRMBL;
-       switch (txctl->antenna_sel_tx) {
-       case 0:
+
+       switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) {
+       case 0: /* Default */
                phy_ctl |= B43_TX4_PHY_ANTLAST;
                break;
-       case 1:
+       case 1: /* Antenna 0 */
                phy_ctl |= B43_TX4_PHY_ANT0;
                break;
-       case 2:
+       case 2: /* Antenna 1 */
                phy_ctl |= B43_TX4_PHY_ANT1;
                break;
        default:
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to