diff --git a/eeprom.c b/eeprom.c index 733558718..b3229aa5d 100644 --- a/eeprom.c +++ b/eeprom.c @@ -80,21 +80,11 @@ mt76_eeprom_override(struct mt76_dev *dev) { #ifdef CONFIG_OF struct device_node *np = dev->dev->of_node; - const __be32 *val; const u8 *mac; - int size; if (!np) return; - val = of_get_property(np, "mediatek,2ghz", &size); - if (val) - dev->cap.has_2ghz = be32_to_cpup(val); - - val = of_get_property(np, "mediatek,5ghz", &size); - if (val) - dev->cap.has_5ghz = be32_to_cpup(val); - mac = of_get_mac_address(np); if (mac) memcpy(dev->macaddr, mac, ETH_ALEN); @@ -107,7 +97,6 @@ mt76_eeprom_override(struct mt76_dev *dev) dev->macaddr); } } -EXPORT_SYMBOL_GPL(mt76_eeprom_override); int mt76_eeprom_init(struct mt76_dev *dev, int len) diff --git a/mac80211.c b/mac80211.c index 765b69d57..fb2427b80 100644 --- a/mac80211.c +++ b/mac80211.c @@ -168,6 +168,31 @@ mt76_init_sband_5g(struct mt76_dev *dev, struct ieee80211_rate *rates, rates, n_rates, vht); } +static void +mt76_check_sband(struct mt76_dev *dev, int band) +{ + struct ieee80211_supported_band *sband = dev->hw->wiphy->bands[band]; + bool found = false; + int i; + + if (!sband) + return; + + for (i = 0; i < sband->n_channels; i++) { + if (sband->channels[i].flags & IEEE80211_CHAN_DISABLED) + continue; + + found = true; + break; + } + + if (found) + return; + + sband->n_channels = 0; + dev->hw->wiphy->bands[band] = NULL; +} + int mt76_register_device(struct mt76_dev *dev, bool vht, struct ieee80211_rate *rates, int n_rates) { @@ -181,6 +206,8 @@ int mt76_register_device(struct mt76_dev *dev, bool vht, spin_lock_init(&dev->cc_lock); INIT_LIST_HEAD(&dev->txwi_cache); + mt76_eeprom_override(dev); + SET_IEEE80211_DEV(hw, dev->dev); SET_IEEE80211_PERM_ADDR(hw, dev->macaddr); @@ -221,6 +248,10 @@ int mt76_register_device(struct mt76_dev *dev, bool vht, return ret; } + wiphy_read_of_freq_limits(dev->hw->wiphy); + mt76_check_sband(dev, NL80211_BAND_2GHZ); + mt76_check_sband(dev, NL80211_BAND_5GHZ); + return ieee80211_register_hw(hw); } EXPORT_SYMBOL_GPL(mt76_register_device); diff --git a/mt76.h b/mt76.h index f94f78a85..0ca6fcb89 100644 --- a/mt76.h +++ b/mt76.h @@ -314,7 +314,6 @@ void mt76_unregister_device(struct mt76_dev *dev); struct dentry *mt76_register_debugfs(struct mt76_dev *dev); int mt76_eeprom_init(struct mt76_dev *dev, int len); -void mt76_eeprom_override(struct mt76_dev *dev); static inline struct ieee80211_txq * mtxq_to_txq(struct mt76_txq *mtxq) @@ -351,5 +350,6 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx, void mt76_tx_free(struct mt76_dev *dev); void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t); void mt76_rx_complete(struct mt76_dev *dev, enum mt76_rxq_id q); +void mt76_eeprom_override(struct mt76_dev *dev); #endif diff --git a/mt7603_eeprom.c b/mt7603_eeprom.c index 79dbd224e..5e95d15df 100644 --- a/mt7603_eeprom.c +++ b/mt7603_eeprom.c @@ -157,7 +157,6 @@ int mt7603_eeprom_init(struct mt7603_dev *dev) ETH_ALEN); mt7603_apply_cal_free_data(dev, dev->mt76.otp.data); - mt76_eeprom_override(&dev->mt76); return 0; } diff --git a/mt76x2_eeprom.c b/mt76x2_eeprom.c index bbfcd3614..ed2151c09 100644 --- a/mt76x2_eeprom.c +++ b/mt76x2_eeprom.c @@ -637,7 +637,6 @@ int mt76x2_eeprom_init(struct mt76x2_dev *dev) mt76x2_eeprom_parse_hw_cap(dev); mt76x2_eeprom_get_macaddr(dev); - mt76_eeprom_override(&dev->mt76); dev->mt76.macaddr[0] &= ~BIT(1); return 0;