Stop returning negative values from ath5k_eeprom_mode_from_channel.
Yell loudly about that case in that function instead and return the
default/zero/mode A. This cleans up the callers, but needs to pass ah
down to ath5k_eeprom_mode_from_channel for ATH5K_WARN. For that
purpose we also need the declaration to be moved to ath5k.h.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Nick Kossifidis <mickflemm@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
 /* EEPROM access functions */
 int ath5k_eeprom_init(struct ath5k_hw *ah);
 void ath5k_eeprom_detach(struct ath5k_hw *ah);
-
+int ath5k_eeprom_mode_from_channel(struct ath5k_hw *ah,
+               struct ieee80211_channel *channel);
 
 /* Protocol Control Unit Functions */
 /* Helpers */
 
 }
 
 int
-ath5k_eeprom_mode_from_channel(struct ieee80211_channel *channel)
+ath5k_eeprom_mode_from_channel(struct ath5k_hw *ah,
+               struct ieee80211_channel *channel)
 {
        switch (channel->hw_value) {
        case AR5K_MODE_11A:
        case AR5K_MODE_11B:
                return AR5K_EEPROM_MODE_11B;
        default:
-               return -1;
+               ATH5K_WARN(ah, "channel is not A/B/G!");
+               return AR5K_EEPROM_MODE_11A;
        }
 }
 
        /* Antenna raw switch tables */
        u32     ee_antenna[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
 };
-
-int
-ath5k_eeprom_mode_from_channel(struct ieee80211_channel *channel);
 
 
        ah->ah_cal_mask |= AR5K_CALIBRATION_NF;
 
-       ee_mode = ath5k_eeprom_mode_from_channel(ah->ah_current_channel);
-       if (WARN_ON(ee_mode < 0)) {
-               ah->ah_cal_mask &= ~AR5K_CALIBRATION_NF;
-               return;
-       }
+       ee_mode = ath5k_eeprom_mode_from_channel(ah, ah->ah_current_channel);
 
        /* completed NF calibration, test threshold */
        nf = ath5k_hw_read_measured_noise_floor(ah);
 
        def_ant = ah->ah_def_ant;
 
-       ee_mode = ath5k_eeprom_mode_from_channel(channel);
-       if (ee_mode < 0) {
-               ATH5K_ERR(ah,
-                       "invalid channel: %d\n", channel->center_freq);
-               return;
-       }
+       ee_mode = ath5k_eeprom_mode_from_channel(ah, channel);
 
        switch (ant_mode) {
        case AR5K_ANTMODE_DEFAULT:
                return -EINVAL;
        }
 
-       ee_mode = ath5k_eeprom_mode_from_channel(channel);
-       if (ee_mode < 0) {
-               ATH5K_ERR(ah,
-                       "invalid channel: %d\n", channel->center_freq);
-               return -EINVAL;
-       }
+       ee_mode = ath5k_eeprom_mode_from_channel(ah, channel);
 
        /* Initialize TX power table */
        switch (ah->ah_radio) {
 
        if (ah->ah_version == AR5K_AR5210)
                return;
 
-       ee_mode = ath5k_eeprom_mode_from_channel(channel);
-       if (WARN_ON(ee_mode < 0))
-               return;
+       ee_mode = ath5k_eeprom_mode_from_channel(ah, channel);
 
        /* Adjust power delta for channel 14 */
        if (channel->center_freq == 2484)