aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2010-12-21 03:30:43 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-12-22 15:43:28 -0500
commit0207c0c51a37659a92232e665f2a7fadec170556 (patch)
treebc5755f6252c47c7722c3e69eee92c7274b36320
parent26a51ad7f285236ca593c57cffcaadd40514084a (diff)
ath5k: Use helper function to get eeprom mode from channel
Introduce a helper function to get the EEPROM mode from channel and remove multiple similar switch statements. Also since it's now easy to get the EEPROM mode from the channel, use them inside the functions which need it, instead of passing a redundant ee_mode parameter. Signed-off-by: Bruno Randolf <br1@einfach.org> Acked-by: Nick Kossifidis <mickflemm@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h2
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c16
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.h2
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c68
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c19
5 files changed, 42 insertions, 65 deletions
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 5de852017651..407e39c2b10b 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -1318,7 +1318,7 @@ void ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode);
1318int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower); 1318int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
1319/* Init function */ 1319/* Init function */
1320int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, 1320int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
1321 u8 mode, u8 ee_mode, bool fast); 1321 u8 mode, bool fast);
1322 1322
1323/* 1323/*
1324 * Functions used internaly 1324 * Functions used internaly
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 97eaa9a4415e..80e625608bac 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -1802,3 +1802,19 @@ ath5k_eeprom_detach(struct ath5k_hw *ah)
1802 for (mode = AR5K_EEPROM_MODE_11A; mode <= AR5K_EEPROM_MODE_11G; mode++) 1802 for (mode = AR5K_EEPROM_MODE_11A; mode <= AR5K_EEPROM_MODE_11G; mode++)
1803 ath5k_eeprom_free_pcal_info(ah, mode); 1803 ath5k_eeprom_free_pcal_info(ah, mode);
1804} 1804}
1805
1806int
1807ath5k_eeprom_mode_from_channel(struct ieee80211_channel *channel)
1808{
1809 switch (channel->hw_value & CHANNEL_MODES) {
1810 case CHANNEL_A:
1811 case CHANNEL_XR:
1812 return AR5K_EEPROM_MODE_11A;
1813 case CHANNEL_G:
1814 return AR5K_EEPROM_MODE_11G;
1815 case CHANNEL_B:
1816 return AR5K_EEPROM_MODE_11B;
1817 default:
1818 return -1;
1819 }
1820}
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.h b/drivers/net/wireless/ath/ath5k/eeprom.h
index 0017006be841..7c09e150dbdc 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.h
+++ b/drivers/net/wireless/ath/ath5k/eeprom.h
@@ -517,3 +517,5 @@ struct ath5k_eeprom_info {
517 u32 ee_antenna[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX]; 517 u32 ee_antenna[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
518}; 518};
519 519
520int
521ath5k_eeprom_mode_from_channel(struct ieee80211_channel *channel);
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index b6e96213e924..9306d5fda675 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1355,20 +1355,7 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah)
1355 return; 1355 return;
1356 } 1356 }
1357 1357
1358 switch (ah->ah_current_channel->hw_value & CHANNEL_MODES) { 1358 ee_mode = ath5k_eeprom_mode_from_channel(ah->ah_current_channel);
1359 case CHANNEL_A:
1360 case CHANNEL_XR:
1361 ee_mode = AR5K_EEPROM_MODE_11A;
1362 break;
1363 case CHANNEL_G:
1364 ee_mode = AR5K_EEPROM_MODE_11G;
1365 break;
1366 default:
1367 case CHANNEL_B:
1368 ee_mode = AR5K_EEPROM_MODE_11B;
1369 break;
1370 }
1371
1372 1359
1373 /* completed NF calibration, test threshold */ 1360 /* completed NF calibration, test threshold */
1374 nf = ath5k_hw_read_measured_noise_floor(ah); 1361 nf = ath5k_hw_read_measured_noise_floor(ah);
@@ -1941,18 +1928,8 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1941 1928
1942 def_ant = ah->ah_def_ant; 1929 def_ant = ah->ah_def_ant;
1943 1930
1944 switch (channel->hw_value & CHANNEL_MODES) { 1931 ee_mode = ath5k_eeprom_mode_from_channel(channel);
1945 case CHANNEL_A: 1932 if (ee_mode < 0) {
1946 case CHANNEL_XR:
1947 ee_mode = AR5K_EEPROM_MODE_11A;
1948 break;
1949 case CHANNEL_G:
1950 ee_mode = AR5K_EEPROM_MODE_11G;
1951 break;
1952 case CHANNEL_B:
1953 ee_mode = AR5K_EEPROM_MODE_11B;
1954 break;
1955 default:
1956 ATH5K_ERR(ah->ah_sc, 1933 ATH5K_ERR(ah->ah_sc,
1957 "invalid channel: %d\n", channel->center_freq); 1934 "invalid channel: %d\n", channel->center_freq);
1958 return; 1935 return;
@@ -3100,11 +3077,11 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
3100 */ 3077 */
3101static int 3078static int
3102ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, 3079ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3103 u8 ee_mode, u8 txpower) 3080 u8 txpower)
3104{ 3081{
3105 struct ath5k_rate_pcal_info rate_info; 3082 struct ath5k_rate_pcal_info rate_info;
3106 struct ieee80211_channel *curr_channel = ah->ah_current_channel; 3083 struct ieee80211_channel *curr_channel = ah->ah_current_channel;
3107 u8 type; 3084 u8 type, ee_mode;
3108 int ret; 3085 int ret;
3109 3086
3110 if (txpower > AR5K_TUNE_MAX_TXPOWER) { 3087 if (txpower > AR5K_TUNE_MAX_TXPOWER) {
@@ -3112,6 +3089,13 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3112 return -EINVAL; 3089 return -EINVAL;
3113 } 3090 }
3114 3091
3092 ee_mode = ath5k_eeprom_mode_from_channel(channel);
3093 if (ee_mode < 0) {
3094 ATH5K_ERR(ah->ah_sc,
3095 "invalid channel: %d\n", channel->center_freq);
3096 return -EINVAL;
3097 }
3098
3115 /* Initialize TX power table */ 3099 /* Initialize TX power table */
3116 switch (ah->ah_radio) { 3100 switch (ah->ah_radio) {
3117 case AR5K_RF5110: 3101 case AR5K_RF5110:
@@ -3208,31 +3192,10 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3208 3192
3209int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) 3193int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
3210{ 3194{
3211 /*Just a try M.F.*/
3212 struct ieee80211_channel *channel = ah->ah_current_channel;
3213 u8 ee_mode;
3214
3215 switch (channel->hw_value & CHANNEL_MODES) {
3216 case CHANNEL_A:
3217 case CHANNEL_XR:
3218 ee_mode = AR5K_EEPROM_MODE_11A;
3219 break;
3220 case CHANNEL_G:
3221 ee_mode = AR5K_EEPROM_MODE_11G;
3222 break;
3223 case CHANNEL_B:
3224 ee_mode = AR5K_EEPROM_MODE_11B;
3225 break;
3226 default:
3227 ATH5K_ERR(ah->ah_sc,
3228 "invalid channel: %d\n", channel->center_freq);
3229 return -EINVAL;
3230 }
3231
3232 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER, 3195 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER,
3233 "changing txpower to %d\n", txpower); 3196 "changing txpower to %d\n", txpower);
3234 3197
3235 return ath5k_hw_txpower(ah, channel, ee_mode, txpower); 3198 return ath5k_hw_txpower(ah, ah->ah_current_channel, txpower);
3236} 3199}
3237 3200
3238/*************\ 3201/*************\
@@ -3240,7 +3203,7 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
3240\*************/ 3203\*************/
3241 3204
3242int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, 3205int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3243 u8 mode, u8 ee_mode, bool fast) 3206 u8 mode, bool fast)
3244{ 3207{
3245 struct ieee80211_channel *curr_channel; 3208 struct ieee80211_channel *curr_channel;
3246 int ret, i; 3209 int ret, i;
@@ -3281,8 +3244,7 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3281 * RF buffer settings on 5211/5212+ so that we 3244 * RF buffer settings on 5211/5212+ so that we
3282 * properly set curve indices. 3245 * properly set curve indices.
3283 */ 3246 */
3284 ret = ath5k_hw_txpower(ah, channel, ee_mode, 3247 ret = ath5k_hw_txpower(ah, channel, ah->ah_txpower.txp_cur_pwr ?
3285 ah->ah_txpower.txp_cur_pwr ?
3286 ah->ah_txpower.txp_cur_pwr / 2 : AR5K_TUNE_MAX_TXPOWER); 3248 ah->ah_txpower.txp_cur_pwr / 2 : AR5K_TUNE_MAX_TXPOWER);
3287 if (ret) 3249 if (ret)
3288 return ret; 3250 return ret;
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index e360e73b3260..84206898f77d 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -866,15 +866,18 @@ static void ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah,
866} 866}
867 867
868static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, 868static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah,
869 struct ieee80211_channel *channel, u8 ee_mode) 869 struct ieee80211_channel *channel)
870{ 870{
871 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 871 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
872 s16 cck_ofdm_pwr_delta; 872 s16 cck_ofdm_pwr_delta;
873 u8 ee_mode;
873 874
874 /* TODO: Add support for AR5210 EEPROM */ 875 /* TODO: Add support for AR5210 EEPROM */
875 if (ah->ah_version == AR5K_AR5210) 876 if (ah->ah_version == AR5K_AR5210)
876 return; 877 return;
877 878
879 ee_mode = ath5k_eeprom_mode_from_channel(channel);
880
878 /* Adjust power delta for channel 14 */ 881 /* Adjust power delta for channel 14 */
879 if (channel->center_freq == 2484) 882 if (channel->center_freq == 2484)
880 cck_ofdm_pwr_delta = 883 cck_ofdm_pwr_delta =
@@ -1020,10 +1023,9 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1020 struct ieee80211_channel *channel, bool fast, bool skip_pcu) 1023 struct ieee80211_channel *channel, bool fast, bool skip_pcu)
1021{ 1024{
1022 u32 s_seq[10], s_led[3], tsf_up, tsf_lo; 1025 u32 s_seq[10], s_led[3], tsf_up, tsf_lo;
1023 u8 mode, ee_mode; 1026 u8 mode;
1024 int i, ret; 1027 int i, ret;
1025 1028
1026 ee_mode = 0;
1027 tsf_up = 0; 1029 tsf_up = 0;
1028 tsf_lo = 0; 1030 tsf_lo = 0;
1029 mode = 0; 1031 mode = 0;
@@ -1070,7 +1072,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1070 switch (channel->hw_value & CHANNEL_MODES) { 1072 switch (channel->hw_value & CHANNEL_MODES) {
1071 case CHANNEL_A: 1073 case CHANNEL_A:
1072 mode = AR5K_MODE_11A; 1074 mode = AR5K_MODE_11A;
1073 ee_mode = AR5K_EEPROM_MODE_11A;
1074 break; 1075 break;
1075 case CHANNEL_G: 1076 case CHANNEL_G:
1076 1077
@@ -1081,7 +1082,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1081 } 1082 }
1082 1083
1083 mode = AR5K_MODE_11G; 1084 mode = AR5K_MODE_11G;
1084 ee_mode = AR5K_EEPROM_MODE_11G;
1085 break; 1085 break;
1086 case CHANNEL_B: 1086 case CHANNEL_B:
1087 1087
@@ -1092,7 +1092,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1092 } 1092 }
1093 1093
1094 mode = AR5K_MODE_11B; 1094 mode = AR5K_MODE_11B;
1095 ee_mode = AR5K_EEPROM_MODE_11B;
1096 break; 1095 break;
1097 case CHANNEL_XR: 1096 case CHANNEL_XR:
1098 if (ah->ah_version == AR5K_AR5211) { 1097 if (ah->ah_version == AR5K_AR5211) {
@@ -1101,7 +1100,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1101 return -EINVAL; 1100 return -EINVAL;
1102 } 1101 }
1103 mode = AR5K_MODE_XR; 1102 mode = AR5K_MODE_XR;
1104 ee_mode = AR5K_EEPROM_MODE_11A;
1105 break; 1103 break;
1106 default: 1104 default:
1107 ATH5K_ERR(ah->ah_sc, 1105 ATH5K_ERR(ah->ah_sc,
@@ -1114,8 +1112,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1114 * go on. If it fails continue with a normal reset. 1112 * go on. If it fails continue with a normal reset.
1115 */ 1113 */
1116 if (fast) { 1114 if (fast) {
1117 ret = ath5k_hw_phy_init(ah, channel, mode, 1115 ret = ath5k_hw_phy_init(ah, channel, mode, true);
1118 ee_mode, true);
1119 if (ret) { 1116 if (ret) {
1120 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_RESET, 1117 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_RESET,
1121 "fast chan change failed, falling back to normal reset\n"); 1118 "fast chan change failed, falling back to normal reset\n");
@@ -1212,7 +1209,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1212 ath5k_hw_tweak_initval_settings(ah, channel); 1209 ath5k_hw_tweak_initval_settings(ah, channel);
1213 1210
1214 /* Commit values from EEPROM */ 1211 /* Commit values from EEPROM */
1215 ath5k_hw_commit_eeprom_settings(ah, channel, ee_mode); 1212 ath5k_hw_commit_eeprom_settings(ah, channel);
1216 1213
1217 1214
1218 /* 1215 /*
@@ -1251,7 +1248,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1251 /* 1248 /*
1252 * Initialize PHY 1249 * Initialize PHY
1253 */ 1250 */
1254 ret = ath5k_hw_phy_init(ah, channel, mode, ee_mode, false); 1251 ret = ath5k_hw_phy_init(ah, channel, mode, false);
1255 if (ret) { 1252 if (ret) {
1256 ATH5K_ERR(ah->ah_sc, 1253 ATH5K_ERR(ah->ah_sc,
1257 "failed to initialize PHY (%i) !\n", ret); 1254 "failed to initialize PHY (%i) !\n", ret);