Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ath9k_hw: store the clock rate in common data on channel changes

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Felix Fietkau and committed by
John W. Linville
dfdac8ac 62c58fb4

+23 -37
+2
drivers/net/wireless/ath/ath.h
··· 145 145 DECLARE_BITMAP(tkip_keymap, ATH_KEYMAX); 146 146 enum ath_crypt_caps crypt_caps; 147 147 148 + unsigned int clockrate; 149 + 148 150 struct ath_regulatory regulatory; 149 151 const struct ath_ops *ops; 150 152 const struct ath_bus_ops *bus_ops;
+2 -24
drivers/net/wireless/ath/ath9k/ani.c
··· 465 465 ath9k_hw_set_cck_nil(ah, aniState->cckNoiseImmunityLevel - 1); 466 466 } 467 467 468 - static u8 ath9k_hw_chan_2_clockrate_mhz(struct ath_hw *ah) 469 - { 470 - struct ath9k_channel *chan = ah->curchan; 471 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; 472 - u8 clockrate; /* in MHz */ 473 - 474 - if (!ah->curchan) /* should really check for CCK instead */ 475 - clockrate = ATH9K_CLOCK_RATE_CCK; 476 - else if (conf->channel->band == IEEE80211_BAND_2GHZ) 477 - clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM; 478 - else if (IS_CHAN_A_FAST_CLOCK(ah, chan)) 479 - clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM; 480 - else 481 - clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM; 482 - 483 - if (conf_is_ht40(conf)) 484 - return clockrate * 2; 485 - 486 - return clockrate; 487 - } 488 - 489 468 static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah) 490 469 { 470 + struct ath_common *common = ath9k_hw_common(ah); 491 471 int32_t listen_time; 492 - int32_t clock_rate; 493 472 494 473 ath9k_hw_update_cycle_counters(ah); 495 - clock_rate = ath9k_hw_chan_2_clockrate_mhz(ah) * 1000; 496 - listen_time = ah->listen_time / clock_rate; 474 + listen_time = ah->listen_time / (common->clockrate * 1000); 497 475 ah->listen_time = 0; 498 476 499 477 return listen_time;
+19 -13
drivers/net/wireless/ath/ath9k/hw.c
··· 88 88 /* Helper Functions */ 89 89 /********************/ 90 90 91 - static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs) 91 + static void ath9k_hw_set_clockrate(struct ath_hw *ah) 92 92 { 93 93 struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; 94 + struct ath_common *common = ath9k_hw_common(ah); 95 + unsigned int clockrate; 94 96 95 97 if (!ah->curchan) /* should really check for CCK instead */ 96 - return usecs *ATH9K_CLOCK_RATE_CCK; 97 - if (conf->channel->band == IEEE80211_BAND_2GHZ) 98 - return usecs *ATH9K_CLOCK_RATE_2GHZ_OFDM; 99 - 100 - if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK) 101 - return usecs * ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM; 98 + clockrate = ATH9K_CLOCK_RATE_CCK; 99 + else if (conf->channel->band == IEEE80211_BAND_2GHZ) 100 + clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM; 101 + else if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK) 102 + clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM; 102 103 else 103 - return usecs * ATH9K_CLOCK_RATE_5GHZ_OFDM; 104 + clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM; 105 + 106 + if (conf_is_ht40(conf)) 107 + clockrate *= 2; 108 + 109 + common->clockrate = clockrate; 104 110 } 105 111 106 112 static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs) 107 113 { 108 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; 114 + struct ath_common *common = ath9k_hw_common(ah); 109 115 110 - if (conf_is_ht40(conf)) 111 - return ath9k_hw_mac_clks(ah, usecs) * 2; 112 - else 113 - return ath9k_hw_mac_clks(ah, usecs); 116 + return usecs * common->clockrate; 114 117 } 115 118 116 119 bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout) ··· 1159 1156 "Failed to set channel\n"); 1160 1157 return false; 1161 1158 } 1159 + ath9k_hw_set_clockrate(ah); 1162 1160 1163 1161 ah->eep_ops->set_txpower(ah, chan, 1164 1162 ath9k_regd_get_ctl(regulatory, chan), ··· 1371 1367 r = ath9k_hw_rf_set_freq(ah, chan); 1372 1368 if (r) 1373 1369 return r; 1370 + 1371 + ath9k_hw_set_clockrate(ah); 1374 1372 1375 1373 ENABLE_REGWRITE_BUFFER(ah); 1376 1374