Skip to content

Commit

Permalink
use wiphy_read_of_freq_limits to parse band capability overrides
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Feb 1, 2017
1 parent 3c8caaf commit 184e068
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
11 changes: 0 additions & 11 deletions eeprom.c
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions mac80211.c
Expand Up @@ -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)
{
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mt76.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion mt7603_eeprom.c
Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion mt76x2_eeprom.c
Expand Up @@ -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;
Expand Down

0 comments on commit 184e068

Please sign in to comment.