ath9k: Fix an operator typo in phy rate validation
[cascardo/linux.git] / drivers / net / wireless / ath9k / rc.c
index 76acd2b..1b71b93 100644 (file)
@@ -490,7 +490,7 @@ static inline int ath_rc_get_nextvalid_txrate(struct ath_rate_table *rate_table,
 
 static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw)
 {
-       if (WLAN_RC_PHY_HT(phy) & !(capflag & WLAN_RC_HT_FLAG))
+       if (WLAN_RC_PHY_HT(phy) && !(capflag & WLAN_RC_HT_FLAG))
                return 0;
        if (WLAN_RC_PHY_DS(phy) && !(capflag & WLAN_RC_DS_FLAG))
                return 0;
@@ -817,7 +817,7 @@ static void ath_rc_ratefind(struct ath_softc *sc,
        struct ath_rate_table *rate_table;
        struct ieee80211_tx_rate *rates = tx_info->control.rates;
 
-       rate_table = sc->hw_rate_table[sc->sc_curmode];
+       rate_table = sc->cur_rate_table;
        rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table, 1,
                                 is_probe, is_retry);
        nrix = rix;
@@ -874,10 +874,9 @@ static void ath_rc_ratefind(struct ath_softc *sc,
         * So, set fourth rate in series to be same as third one for
         * above conditions.
         */
-       if ((sc->sc_curmode == ATH9K_MODE_11NG_HT20) ||
-           (sc->sc_curmode == ATH9K_MODE_11NG_HT40PLUS) ||
-           (sc->sc_curmode == ATH9K_MODE_11NG_HT40MINUS)) {
-               u8  dot11rate = rate_table->info[rix].dot11rate;
+       if ((sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ) &&
+           (sc->hw->conf.ht.enabled)) {
+               u8 dot11rate = rate_table->info[rix].dot11rate;
                u8 phy = rate_table->info[rix].phy;
                if (i == 4 &&
                    ((dot11rate == 2 && phy == WLAN_RC_PHY_HT_40_SS) ||
@@ -1094,7 +1093,7 @@ static void ath_rc_update_ht(struct ath_softc *sc,
        int rate;
        u8 last_per;
        bool state_change = false;
-       struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode];
+       struct ath_rate_table *rate_table = sc->cur_rate_table;
        int size = ath_rc_priv->rate_table_size;
 
        if ((tx_rate < 0) || (tx_rate > rate_table->rate_cnt))
@@ -1254,7 +1253,7 @@ static void ath_rc_tx_status(struct ath_softc *sc,
        u8 flags;
        u32 i = 0, rix;
 
-       rate_table = sc->hw_rate_table[sc->sc_curmode];
+       rate_table = sc->cur_rate_table;
 
        /*
         * If the first rate is not the final index, there
@@ -1354,8 +1353,8 @@ static void ath_rc_init(struct ath_softc *sc,
                                                   sta->ht_cap.ht_supported,
                                                   is_cw_40);
        } else if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_AP) {
-               /* sc_curmode would be set on init through config() */
-               rate_table = sc->hw_rate_table[sc->sc_curmode];
+               /* cur_rate_table would be set on init through config() */
+               rate_table = sc->cur_rate_table;
        }
 
        if (!rate_table) {
@@ -1432,6 +1431,7 @@ static void ath_rc_init(struct ath_softc *sc,
        ath_rc_priv->max_valid_rate = k;
        ath_rc_sort_validrates(rate_table, ath_rc_priv);
        ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4];
+       sc->cur_rate_table = rate_table;
 }
 
 /* Rate Control callbacks */
@@ -1498,7 +1498,8 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
        __le16 fc = hdr->frame_control;
 
        /* lowest rate for management and multicast/broadcast frames */
-       if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) {
+       if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) ||
+           !sta) {
                tx_info->control.rates[0].idx = rate_lowest_index(sband, sta);
                tx_info->control.rates[0].count =
                        is_multicast_ether_addr(hdr->addr1) ? 1 : ATH_MGT_TXMAXTRY;