1 --- a/drivers/net/wireless/ath/ath9k/init.c
2 +++ b/drivers/net/wireless/ath/ath9k/init.c
3 @@ -654,6 +654,37 @@ err_hw:
7 +static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
9 + struct ieee80211_supported_band *sband;
10 + struct ieee80211_channel *chan;
11 + struct ath_hw *ah = sc->sc_ah;
12 + struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
15 + sband = &sc->sbands[band];
16 + for (i = 0; i < sband->n_channels; i++) {
17 + chan = &sband->channels[i];
18 + ah->curchan = &ah->channels[chan->hw_value];
19 + ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20);
20 + ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
21 + chan->max_power = reg->max_power_level / 2;
25 +static void ath9k_init_txpower_limits(struct ath_softc *sc)
27 + struct ath_hw *ah = sc->sc_ah;
28 + struct ath9k_channel *curchan = ah->curchan;
30 + if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
31 + ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ);
32 + if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
33 + ath9k_init_band_txpower(sc, IEEE80211_BAND_5GHZ);
35 + ah->curchan = curchan;
38 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
40 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
41 @@ -748,6 +779,8 @@ int ath9k_init_device(u16 devid, struct
45 + ath9k_init_txpower_limits(sc);
47 /* Register with mac80211 */
48 error = ieee80211_register_hw(hw);
50 --- a/drivers/net/wireless/ath/ath9k/common.c
51 +++ b/drivers/net/wireless/ath/ath9k/common.c
52 @@ -107,12 +107,10 @@ static u32 ath9k_get_extchanmode(struct
54 * Update internal channel flags.
56 -void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
57 - struct ath9k_channel *ichan)
58 +void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
59 + struct ieee80211_channel *chan,
60 + enum nl80211_channel_type channel_type)
62 - struct ieee80211_channel *chan = hw->conf.channel;
63 - struct ieee80211_conf *conf = &hw->conf;
65 ichan->channel = chan->center_freq;
68 @@ -124,9 +122,8 @@ void ath9k_cmn_update_ichannel(struct ie
69 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
72 - if (conf_is_ht(conf))
73 - ichan->chanmode = ath9k_get_extchanmode(chan,
74 - conf->channel_type);
75 + if (channel_type != NL80211_CHAN_NO_HT)
76 + ichan->chanmode = ath9k_get_extchanmode(chan, channel_type);
78 EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
80 @@ -142,7 +139,7 @@ struct ath9k_channel *ath9k_cmn_get_curc
82 chan_idx = curchan->hw_value;
83 channel = &ah->channels[chan_idx];
84 - ath9k_cmn_update_ichannel(hw, channel);
85 + ath9k_cmn_update_ichannel(channel, curchan, hw->conf.channel_type);
89 --- a/drivers/net/wireless/ath/ath9k/common.h
90 +++ b/drivers/net/wireless/ath/ath9k/common.h
91 @@ -62,8 +62,9 @@ enum ath_stomp_type {
93 int ath9k_cmn_padpos(__le16 frame_control);
94 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
95 -void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
96 - struct ath9k_channel *ichan);
97 +void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
98 + struct ieee80211_channel *chan,
99 + enum nl80211_channel_type channel_type);
100 struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
102 int ath9k_cmn_count_streams(unsigned int chainmask, int max);
103 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
104 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
105 @@ -1405,7 +1405,9 @@ static int ath9k_htc_config(struct ieee8
106 ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
107 curchan->center_freq);
109 - ath9k_cmn_update_ichannel(hw, &priv->ah->channels[pos]);
110 + ath9k_cmn_update_ichannel(&priv->ah->channels[pos],
112 + hw->conf.channel_type);
114 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
115 ath_print(common, ATH_DBG_FATAL,