ath9k: enable rx for tx antennas earlier (and only for multi-stream devices) to fix...
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 561-ath9k_antenna_mask_validate.patch
1 --- a/drivers/net/wireless/ath/ath9k/main.c
2 +++ b/drivers/net/wireless/ath/ath9k/main.c
3 @@ -1929,12 +1929,29 @@ static u32 fill_chainmask(u32 cap, u32 n
4 return filled;
5 }
6
7 +static bool validate_antenna_mask(struct ath_hw *ah, u32 val)
8 +{
9 + switch (val & ah->caps.rx_chainmask) {
10 + case 0x1:
11 + case 0x3:
12 + case 0x7:
13 + return true;
14 + case 0x2:
15 + return (ah->caps.rx_chainmask == 1);
16 + default:
17 + return false;
18 + }
19 +}
20 +
21 static int ath9k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
22 {
23 struct ath_softc *sc = hw->priv;
24 struct ath_hw *ah = sc->sc_ah;
25
26 - if (!rx_ant || !tx_ant)
27 + if (ah->caps.rx_chainmask != 1)
28 + rx_ant |= tx_ant;
29 +
30 + if (!validate_antenna_mask(ah, rx_ant) || !tx_ant)
31 return -EINVAL;
32
33 sc->ant_rx = rx_ant;