Search Linux Wireless

Re: [PATCH 5/5] ath5k: Use helper function to get eeprom mode from channel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/12/21 Bruno Randolf <br1@xxxxxxxxxxx>:
> 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@xxxxxxxxxxx>
> ---
> Âdrivers/net/wireless/ath/ath5k/ath5k.h Â| Â Â2 -
> Âdrivers/net/wireless/ath/ath5k/eeprom.c | Â 16 +++++++
> Âdrivers/net/wireless/ath/ath5k/eeprom.h | Â Â2 +
> Âdrivers/net/wireless/ath/ath5k/phy.c  Â|  68 +++++++------------------------
> Âdrivers/net/wireless/ath/ath5k/reset.c Â| Â 19 ++++-----
> Â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 5de8520..407e39c 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);
> Âint ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
> Â/* Init function */
> Âint ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â u8 mode, u8 ee_mode, bool fast);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â u8 mode, bool fast);
>
> Â/*
> Â* Functions used internaly
> diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
> index 97eaa9a..80e6256 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)
> Â Â Â Âfor (mode = AR5K_EEPROM_MODE_11A; mode <= AR5K_EEPROM_MODE_11G; mode++)
> Â Â Â Â Â Â Â Âath5k_eeprom_free_pcal_info(ah, mode);
> Â}
> +
> +int
> +ath5k_eeprom_mode_from_channel(struct ieee80211_channel *channel)
> +{
> + Â Â Â switch (channel->hw_value & CHANNEL_MODES) {
> + Â Â Â case CHANNEL_A:
> + Â Â Â case CHANNEL_XR:
> + Â Â Â Â Â Â Â return AR5K_EEPROM_MODE_11A;
> + Â Â Â case CHANNEL_G:
> + Â Â Â Â Â Â Â return AR5K_EEPROM_MODE_11G;
> + Â Â Â case CHANNEL_B:
> + Â Â Â Â Â Â Â return AR5K_EEPROM_MODE_11B;
> + Â Â Â default:
> + Â Â Â Â Â Â Â return -1;
> + Â Â Â }
> +}
> diff --git a/drivers/net/wireless/ath/ath5k/eeprom.h b/drivers/net/wireless/ath/ath5k/eeprom.h
> index 0017006..7c09e15 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 {
> Â Â Â Âu32 Â Â ee_antenna[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
> Â};
>
> +int
> +ath5k_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 b6e9621..9306d5f 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)
> Â Â Â Â Â Â Â Âreturn;
> Â Â Â Â}
>
> - Â Â Â switch (ah->ah_current_channel->hw_value & CHANNEL_MODES) {
> - Â Â Â case CHANNEL_A:
> - Â Â Â case CHANNEL_XR:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11A;
> - Â Â Â Â Â Â Â break;
> - Â Â Â case CHANNEL_G:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11G;
> - Â Â Â Â Â Â Â break;
> - Â Â Â default:
> - Â Â Â case CHANNEL_B:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11B;
> - Â Â Â Â Â Â Â break;
> - Â Â Â }
> -
> + Â Â Â ee_mode = ath5k_eeprom_mode_from_channel(ah->ah_current_channel);
>
> Â Â Â Â/* completed NF calibration, test threshold */
> Â Â Â Ânf = ath5k_hw_read_measured_noise_floor(ah);
> @@ -1941,18 +1928,8 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
>
> Â Â Â Âdef_ant = ah->ah_def_ant;
>
> - Â Â Â switch (channel->hw_value & CHANNEL_MODES) {
> - Â Â Â case CHANNEL_A:
> - Â Â Â case CHANNEL_XR:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11A;
> - Â Â Â Â Â Â Â break;
> - Â Â Â case CHANNEL_G:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11G;
> - Â Â Â Â Â Â Â break;
> - Â Â Â case CHANNEL_B:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11B;
> - Â Â Â Â Â Â Â break;
> - Â Â Â default:
> + Â Â Â ee_mode = ath5k_eeprom_mode_from_channel(channel);
> + Â Â Â if (ee_mode < 0) {
> Â Â Â Â Â Â Â ÂATH5K_ERR(ah->ah_sc,
> Â Â Â Â Â Â Â Â Â Â Â Â"invalid channel: %d\n", channel->center_freq);
> Â Â Â Â Â Â Â Âreturn;
> @@ -3100,11 +3077,11 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
> Â*/
> Âstatic int
> Âath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
> - Â Â Â Â Â Â Â u8 ee_mode, u8 txpower)
> + Â Â Â Â Â Â Â Âu8 txpower)
> Â{
> Â Â Â Âstruct ath5k_rate_pcal_info rate_info;
> Â Â Â Âstruct ieee80211_channel *curr_channel = ah->ah_current_channel;
> - Â Â Â u8 type;
> + Â Â Â u8 type, ee_mode;
> Â Â Â Âint ret;
>
> Â Â Â Âif (txpower > AR5K_TUNE_MAX_TXPOWER) {
> @@ -3112,6 +3089,13 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
> Â Â Â Â Â Â Â Âreturn -EINVAL;
> Â Â Â Â}
>
> + Â Â Â ee_mode = ath5k_eeprom_mode_from_channel(channel);
> + Â Â Â if (ee_mode < 0) {
> + Â Â Â Â Â Â Â ATH5K_ERR(ah->ah_sc,
> + Â Â Â Â Â Â Â Â Â Â Â "invalid channel: %d\n", channel->center_freq);
> + Â Â Â Â Â Â Â return -EINVAL;
> + Â Â Â }
> +
> Â Â Â Â/* Initialize TX power table */
> Â Â Â Âswitch (ah->ah_radio) {
> Â Â Â Âcase AR5K_RF5110:
> @@ -3208,31 +3192,10 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
>
> Âint ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
> Â{
> - Â Â Â /*Just a try M.F.*/
> - Â Â Â struct ieee80211_channel *channel = ah->ah_current_channel;
> - Â Â Â u8 ee_mode;
> -
> - Â Â Â switch (channel->hw_value & CHANNEL_MODES) {
> - Â Â Â case CHANNEL_A:
> - Â Â Â case CHANNEL_XR:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11A;
> - Â Â Â Â Â Â Â break;
> - Â Â Â case CHANNEL_G:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11G;
> - Â Â Â Â Â Â Â break;
> - Â Â Â case CHANNEL_B:
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11B;
> - Â Â Â Â Â Â Â break;
> - Â Â Â default:
> - Â Â Â Â Â Â Â ATH5K_ERR(ah->ah_sc,
> - Â Â Â Â Â Â Â Â Â Â Â "invalid channel: %d\n", channel->center_freq);
> - Â Â Â Â Â Â Â return -EINVAL;
> - Â Â Â }
> -
> Â Â Â ÂATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER,
> Â Â Â Â Â Â Â Â"changing txpower to %d\n", txpower);
>
> - Â Â Â return ath5k_hw_txpower(ah, channel, ee_mode, txpower);
> + Â Â Â return ath5k_hw_txpower(ah, ah->ah_current_channel, txpower);
> Â}
>
> Â/*************\
> @@ -3240,7 +3203,7 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
> Â\*************/
>
> Âint ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â u8 mode, u8 ee_mode, bool fast)
> + Â Â Â Â Â Â Â Â Â Â u8 mode, bool fast)
> Â{
> Â Â Â Âstruct ieee80211_channel *curr_channel;
> Â Â Â Âint ret, i;
> @@ -3281,8 +3244,7 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
> Â Â Â Â * RF buffer settings on 5211/5212+ so that we
> Â Â Â Â * properly set curve indices.
> Â Â Â Â */
> - Â Â Â ret = ath5k_hw_txpower(ah, channel, ee_mode,
> - Â Â Â Â Â Â Â ah->ah_txpower.txp_cur_pwr ?
> + Â Â Â ret = ath5k_hw_txpower(ah, channel, ah->ah_txpower.txp_cur_pwr ?
> Â Â Â Â Â Â Â Â Â Â Â Âah->ah_txpower.txp_cur_pwr / 2 : AR5K_TUNE_MAX_TXPOWER);
> Â Â Â Âif (ret)
> Â Â Â Â Â Â Â Âreturn ret;
> diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
> index 4b8b987..3c962f7 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,
> Â}
>
> Âstatic void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah,
> - Â Â Â Â Â Â Â struct ieee80211_channel *channel, u8 ee_mode)
> + Â Â Â Â Â Â Â struct ieee80211_channel *channel)
> Â{
> Â Â Â Âstruct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
> Â Â Â Âs16 cck_ofdm_pwr_delta;
> + Â Â Â u8 ee_mode;
>
> Â Â Â Â/* TODO: Add support for AR5210 EEPROM */
> Â Â Â Âif (ah->ah_version == AR5K_AR5210)
> Â Â Â Â Â Â Â Âreturn;
>
> + Â Â Â ee_mode = ath5k_eeprom_mode_from_channel(channel);
> +
> Â Â Â Â/* Adjust power delta for channel 14 */
> Â Â Â Âif (channel->center_freq == 2484)
> Â Â Â Â Â Â Â Âcck_ofdm_pwr_delta =
> @@ -1020,10 +1023,9 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
> Â Â Â Â Â Â Â Âstruct ieee80211_channel *channel, bool fast, bool skip_pcu)
> Â{
> Â Â Â Âu32 s_seq[10], s_led[3], tsf_up, tsf_lo;
> - Â Â Â u8 mode, ee_mode;
> + Â Â Â u8 mode;
> Â Â Â Âint i, ret;
>
> - Â Â Â ee_mode = 0;
> Â Â Â Âtsf_up = 0;
> Â Â Â Âtsf_lo = 0;
> Â Â Â Âmode = 0;
> @@ -1070,7 +1072,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
> Â Â Â Âswitch (channel->hw_value & CHANNEL_MODES) {
> Â Â Â Âcase CHANNEL_A:
> Â Â Â Â Â Â Â Âmode = AR5K_MODE_11A;
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11A;
> Â Â Â Â Â Â Â Âbreak;
> Â Â Â Âcase CHANNEL_G:
>
> @@ -1081,7 +1082,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
> Â Â Â Â Â Â Â Â}
>
> Â Â Â Â Â Â Â Âmode = AR5K_MODE_11G;
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11G;
> Â Â Â Â Â Â Â Âbreak;
> Â Â Â Âcase CHANNEL_B:
>
> @@ -1092,7 +1092,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
> Â Â Â Â Â Â Â Â}
>
> Â Â Â Â Â Â Â Âmode = AR5K_MODE_11B;
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11B;
> Â Â Â Â Â Â Â Âbreak;
> Â Â Â Âcase CHANNEL_XR:
> Â Â Â Â Â Â Â Âif (ah->ah_version == AR5K_AR5211) {
> @@ -1101,7 +1100,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
> Â Â Â Â Â Â Â Â Â Â Â Âreturn -EINVAL;
> Â Â Â Â Â Â Â Â}
> Â Â Â Â Â Â Â Âmode = AR5K_MODE_XR;
> - Â Â Â Â Â Â Â ee_mode = AR5K_EEPROM_MODE_11A;
> Â Â Â Â Â Â Â Âbreak;
> Â Â Â Âdefault:
> Â Â Â Â Â Â Â ÂATH5K_ERR(ah->ah_sc,
> @@ -1114,8 +1112,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
> Â Â Â Â * go on. If it fails continue with a normal reset.
> Â Â Â Â */
> Â Â Â Âif (fast) {
> - Â Â Â Â Â Â Â ret = ath5k_hw_phy_init(ah, channel, mode,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ee_mode, true);
> + Â Â Â Â Â Â Â ret = ath5k_hw_phy_init(ah, channel, mode, true);
> Â Â Â Â Â Â Â Âif (ret) {
> Â Â Â Â Â Â Â Â Â Â Â ÂATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_RESET,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â"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,
> Â Â Â Âath5k_hw_tweak_initval_settings(ah, channel);
>
> Â Â Â Â/* Commit values from EEPROM */
> - Â Â Â ath5k_hw_commit_eeprom_settings(ah, channel, ee_mode);
> + Â Â Â ath5k_hw_commit_eeprom_settings(ah, channel);
>
>
> Â Â Â Â/*
> @@ -1251,7 +1248,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
> Â Â Â Â/*
> Â Â Â Â * Initialize PHY
> Â Â Â Â */
> - Â Â Â ret = ath5k_hw_phy_init(ah, channel, mode, ee_mode, false);
> + Â Â Â ret = ath5k_hw_phy_init(ah, channel, mode, false);
> Â Â Â Âif (ret) {
> Â Â Â Â Â Â Â ÂATH5K_ERR(ah->ah_sc,
> Â Â Â Â Â Â Â Â Â Â Â Â"failed to initialize PHY (%i) !\n", ret);
>
>

Acked-by: Nick Kossifidis <mickflemm@xxxxxxxxx>


-- 
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux