From be2bea66d6e36251f0f3615fb69aca5b5a4cea9d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 21 Jan 2021 11:39:07 +0100 Subject: [PATCH] mt76: mt7915: detect wrong nss eeprom parameter on dbdc cards Signed-off-by: Felix Fietkau --- mt7915/eeprom.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c index 9f07d2af..a7ffc20b 100644 --- a/mt7915/eeprom.c +++ b/mt7915/eeprom.c @@ -73,7 +73,7 @@ void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy) static void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev) { - u8 nss, *eeprom = dev->mt76.eeprom.data; + u8 nss, nss_band, *eeprom = dev->mt76.eeprom.data; mt7915_eeprom_parse_band_config(&dev->phy); @@ -82,16 +82,20 @@ static void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev) if (!nss || nss > 4) nss = 4; - dev->chainmask = BIT(nss) - 1; + nss_band = nss; if (dev->dbdc_support) { - nss = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B0, - eeprom[MT_EE_WIFI_CONF + 3]); - if (!nss || nss > 2) - nss = 2; + nss_band = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B0, + eeprom[MT_EE_WIFI_CONF + 3]); + if (!nss_band || nss_band > 2) + nss_band = 2; + + if (nss_band >= nss) + nss = 4; } - dev->mphy.antenna_mask = BIT(nss) - 1; + dev->chainmask = BIT(nss) - 1; + dev->mphy.antenna_mask = BIT(nss_band) - 1; dev->mphy.chainmask = dev->mphy.antenna_mask; }