ath9k: enable 2GHz band only if the device supports it
authorGabor Juhos <juhosg@openwrt.org>
Fri, 27 Nov 2009 11:01:35 +0000 (12:01 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 4 Dec 2009 19:16:23 +0000 (14:16 -0500)
Currently, the 2GHz band is enabled unconditionally, even if the device
does not support it.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/hw.h
drivers/net/wireless/ath/ath9k/main.c

index 493160c8c754428d833710f5631310cbcbecbc02..2ec61f08cfdbb073ea02adc1a1947ddf66336793 100644 (file)
@@ -976,7 +976,10 @@ int ath9k_hw_init(struct ath_hw *ah)
                return r;
 
        ath9k_hw_init_mode_gain_regs(ah);
-       ath9k_hw_fill_cap_info(ah);
+       r = ath9k_hw_fill_cap_info(ah);
+       if (r)
+               return r;
+
        ath9k_hw_init_11a_eeprom_fix(ah);
 
        r = ath9k_hw_init_macaddr(ah);
@@ -3112,7 +3115,7 @@ EXPORT_SYMBOL(ath9k_hw_set_sta_beacon_timers);
 /* HW Capabilities */
 /*******************/
 
-void ath9k_hw_fill_cap_info(struct ath_hw *ah)
+int ath9k_hw_fill_cap_info(struct ath_hw *ah)
 {
        struct ath9k_hw_capabilities *pCap = &ah->caps;
        struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
@@ -3143,6 +3146,12 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
        }
 
        eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
+       if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
+               ath_print(common, ATH_DBG_FATAL,
+                         "no band has been marked as supported in EEPROM.\n");
+               return -EINVAL;
+       }
+
        bitmap_zero(pCap->wireless_modes, ATH9K_MODE_MAX);
 
        if (eeval & AR5416_OPFLAGS_11A) {
@@ -3306,6 +3315,8 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
        } else {
                btcoex_hw->scheme = ATH_BTCOEX_CFG_NONE;
        }
+
+       return 0;
 }
 
 bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
index 46e1572dc9459c3cfb146499de67b1b080c36e6d..e2b0c73a616f30ac5834a6bc0a2abb9b7ce7259a 100644 (file)
@@ -620,7 +620,7 @@ void ath9k_hw_detach(struct ath_hw *ah);
 int ath9k_hw_init(struct ath_hw *ah);
 int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
                   bool bChannelChange);
-void ath9k_hw_fill_cap_info(struct ath_hw *ah);
+int ath9k_hw_fill_cap_info(struct ath_hw *ah);
 bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
                            u32 capability, u32 *result);
 bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type,
index b9598148767bfc81a9ad7239bb069be83f617eac..c48743452515c16c5fdae713ceeda416156fccab 100644 (file)
@@ -1793,13 +1793,15 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
 
        /* setup channels and rates */
 
-       sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
-       sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
-       sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
-               ARRAY_SIZE(ath9k_2ghz_chantable);
-       sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
-       sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
-               ARRAY_SIZE(ath9k_legacy_rates);
+       if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) {
+               sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
+               sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
+               sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
+                       ARRAY_SIZE(ath9k_2ghz_chantable);
+               sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
+               sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
+                       ARRAY_SIZE(ath9k_legacy_rates);
+       }
 
        if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
                sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable;
@@ -1876,8 +1878,9 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
 
        hw->rate_control_algorithm = "ath9k_rate_control";
 
-       hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
-               &sc->sbands[IEEE80211_BAND_2GHZ];
+       if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes))
+               hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
+                       &sc->sbands[IEEE80211_BAND_2GHZ];
        if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes))
                hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
                        &sc->sbands[IEEE80211_BAND_5GHZ];
@@ -1916,9 +1919,12 @@ int ath_init_device(u16 devid, struct ath_softc *sc, u16 subsysid,
        reg = &common->regulatory;
 
        if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
-               setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
+               if (test_bit(ATH9K_MODE_11G, ah->caps.wireless_modes))
+                       setup_ht_cap(sc,
+                                    &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
                if (test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes))
-                       setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
+                       setup_ht_cap(sc,
+                                    &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
        }
 
        /* initialize tx/rx engine */