ed07822e7cc6112254ed23e661ac98deaa06d213
[openwrt-10.03/.git] / package / mac80211 / patches / 550-ath9k-enable-2GHz-band-only-if-the-device-supports.patch
1 --- a/drivers/net/wireless/ath/ath9k/hw.c
2 +++ b/drivers/net/wireless/ath/ath9k/hw.c
3 @@ -979,7 +979,10 @@ int ath9k_hw_init(struct ath_hw *ah)
4                 return r;
5  
6         ath9k_hw_init_mode_gain_regs(ah);
7 -       ath9k_hw_fill_cap_info(ah);
8 +       r = ath9k_hw_fill_cap_info(ah);
9 +       if (r)
10 +               return r;
11 +
12         ath9k_hw_init_11a_eeprom_fix(ah);
13  
14         r = ath9k_hw_init_macaddr(ah);
15 @@ -3115,7 +3118,7 @@ EXPORT_SYMBOL(ath9k_hw_set_sta_beacon_ti
16  /* HW Capabilities */
17  /*******************/
18  
19 -void ath9k_hw_fill_cap_info(struct ath_hw *ah)
20 +int ath9k_hw_fill_cap_info(struct ath_hw *ah)
21  {
22         struct ath9k_hw_capabilities *pCap = &ah->caps;
23         struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
24 @@ -3146,6 +3149,12 @@ void ath9k_hw_fill_cap_info(struct ath_h
25         }
26  
27         eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
28 +       if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
29 +               ath_print(common, ATH_DBG_FATAL,
30 +                         "no band has been marked as supported in EEPROM.\n");
31 +               return -EINVAL;
32 +       }
33 +
34         bitmap_zero(pCap->wireless_modes, ATH9K_MODE_MAX);
35  
36         if (eeval & AR5416_OPFLAGS_11A) {
37 @@ -3305,6 +3314,8 @@ void ath9k_hw_fill_cap_info(struct ath_h
38         } else {
39                 btcoex_hw->scheme = ATH_BTCOEX_CFG_NONE;
40         }
41 +
42 +       return 0;
43  }
44  
45  bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
46 --- a/drivers/net/wireless/ath/ath9k/hw.h
47 +++ b/drivers/net/wireless/ath/ath9k/hw.h
48 @@ -619,7 +619,7 @@ void ath9k_hw_detach(struct ath_hw *ah);
49  int ath9k_hw_init(struct ath_hw *ah);
50  int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
51                    bool bChannelChange);
52 -void ath9k_hw_fill_cap_info(struct ath_hw *ah);
53 +int ath9k_hw_fill_cap_info(struct ath_hw *ah);
54  bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
55                             u32 capability, u32 *result);
56  bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type,
57 --- a/drivers/net/wireless/ath/ath9k/main.c
58 +++ b/drivers/net/wireless/ath/ath9k/main.c
59 @@ -1805,13 +1805,15 @@ static int ath_init_softc(u16 devid, str
60  
61         /* setup channels and rates */
62  
63 -       sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
64 -       sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
65 -       sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
66 -               ARRAY_SIZE(ath9k_2ghz_chantable);
67 -       sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
68 -       sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
69 -               ARRAY_SIZE(ath9k_legacy_rates);
70 +       if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) {
71 +               sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
72 +               sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
73 +               sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
74 +                       ARRAY_SIZE(ath9k_2ghz_chantable);
75 +               sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
76 +               sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
77 +                       ARRAY_SIZE(ath9k_legacy_rates);
78 +       }
79  
80         if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
81                 sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable;
82 @@ -1886,8 +1888,9 @@ void ath_set_hw_capab(struct ath_softc *
83  
84         hw->rate_control_algorithm = "ath9k_rate_control";
85  
86 -       hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
87 -               &sc->sbands[IEEE80211_BAND_2GHZ];
88 +       if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes))
89 +               hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
90 +                       &sc->sbands[IEEE80211_BAND_2GHZ];
91         if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes))
92                 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
93                         &sc->sbands[IEEE80211_BAND_5GHZ];
94 @@ -1926,9 +1929,12 @@ int ath_init_device(u16 devid, struct at
95         reg = &common->regulatory;
96  
97         if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
98 -               setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
99 +               if (test_bit(ATH9K_MODE_11G, ah->caps.wireless_modes))
100 +                       setup_ht_cap(sc,
101 +                                    &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
102                 if (test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes))
103 -                       setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
104 +                       setup_ht_cap(sc,
105 +                                    &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
106         }
107  
108         /* initialize tx/rx engine */