1 --- a/drivers/net/wireless/ath/ath.h
2 +++ b/drivers/net/wireless/ath/ath.h
3 @@ -145,6 +145,8 @@ struct ath_common {
4 DECLARE_BITMAP(tkip_keymap, ATH_KEYMAX);
5 enum ath_crypt_caps crypt_caps;
7 + unsigned int clockrate;
9 struct ath_regulatory regulatory;
10 const struct ath_ops *ops;
11 const struct ath_bus_ops *bus_ops;
12 --- a/drivers/net/wireless/ath/ath9k/hw.c
13 +++ b/drivers/net/wireless/ath/ath9k/hw.c
14 @@ -91,29 +91,32 @@ static void ath9k_hw_ani_cache_ini_regs(
15 /* Helper Functions */
16 /********************/
18 -static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs)
19 +static void ath9k_hw_set_clockrate(struct ath_hw *ah)
21 struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
22 + struct ath_common *common = ath9k_hw_common(ah);
23 + unsigned int clockrate;
25 if (!ah->curchan) /* should really check for CCK instead */
26 - return usecs *ATH9K_CLOCK_RATE_CCK;
27 - if (conf->channel->band == IEEE80211_BAND_2GHZ)
28 - return usecs *ATH9K_CLOCK_RATE_2GHZ_OFDM;
30 - if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)
31 - return usecs * ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
32 + clockrate = ATH9K_CLOCK_RATE_CCK;
33 + else if (conf->channel->band == IEEE80211_BAND_2GHZ)
34 + clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
35 + else if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)
36 + clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
38 - return usecs * ATH9K_CLOCK_RATE_5GHZ_OFDM;
39 + clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;
41 + if (conf_is_ht40(conf))
44 + common->clockrate = clockrate;
47 static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs)
49 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
50 + struct ath_common *common = ath9k_hw_common(ah);
52 - if (conf_is_ht40(conf))
53 - return ath9k_hw_mac_clks(ah, usecs) * 2;
55 - return ath9k_hw_mac_clks(ah, usecs);
56 + return usecs * common->clockrate;
59 bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout)
60 @@ -1168,6 +1171,7 @@ static bool ath9k_hw_channel_change(stru
61 "Failed to set channel\n");
64 + ath9k_hw_set_clockrate(ah);
66 ah->eep_ops->set_txpower(ah, chan,
67 ath9k_regd_get_ctl(regulatory, chan),
68 @@ -1380,6 +1384,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
72 + ath9k_hw_set_clockrate(ah);
74 ENABLE_REGWRITE_BUFFER(ah);
76 for (i = 0; i < AR_NUM_DCU; i++)
77 --- a/drivers/net/wireless/ath/ath9k/ani.c
78 +++ b/drivers/net/wireless/ath/ath9k/ani.c
79 @@ -465,35 +465,13 @@ static void ath9k_hw_ani_lower_immunity(
80 ath9k_hw_set_cck_nil(ah, aniState->cckNoiseImmunityLevel - 1);
83 -static u8 ath9k_hw_chan_2_clockrate_mhz(struct ath_hw *ah)
85 - struct ath9k_channel *chan = ah->curchan;
86 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
87 - u8 clockrate; /* in MHz */
89 - if (!ah->curchan) /* should really check for CCK instead */
90 - clockrate = ATH9K_CLOCK_RATE_CCK;
91 - else if (conf->channel->band == IEEE80211_BAND_2GHZ)
92 - clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
93 - else if (IS_CHAN_A_FAST_CLOCK(ah, chan))
94 - clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
96 - clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;
98 - if (conf_is_ht40(conf))
99 - return clockrate * 2;
104 static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah)
106 + struct ath_common *common = ath9k_hw_common(ah);
108 - int32_t clock_rate;
110 ath9k_hw_update_cycle_counters(ah);
111 - clock_rate = ath9k_hw_chan_2_clockrate_mhz(ah) * 1000;
112 - listen_time = ah->listen_time / clock_rate;
113 + listen_time = ah->listen_time / (common->clockrate * 1000);