mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
use wiphy_read_of_freq_limits to parse band capability overrides
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
@@ -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)
|
||||
|
||||
+31
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user