diff options
author | Felix Fietkau <nbd@nbd.name> | 2020-02-11 21:00:56 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2020-02-14 10:06:09 +0100 |
commit | 07cda406308b7d11cb77c406044b52752049e78d (patch) | |
tree | cb9b66f7cbf44233af2dc4544f961bd5e04100a2 /drivers/net/wireless/mediatek/mt76/mt7615/init.c | |
parent | 049019c2a07d7b6c86fff9885cb96ab3095f6583 (diff) | |
download | lwn-07cda406308b7d11cb77c406044b52752049e78d.tar.gz lwn-07cda406308b7d11cb77c406044b52752049e78d.zip |
mt76: fix rounding issues on converting per-chain and combined txpower
Unify code converting between the different txpower values. Always add/remove
the combined txpower delta before dividing half-dB values.
Also fix the combined txpower delta values. The correct half-dB delta for
3 chains is 9, not 8.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt7615/init.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7615/init.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c index 4c9f52e04bb8..889eb72ad6bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c @@ -269,6 +269,7 @@ mt7615_init_txpower(struct mt7615_dev *dev, int i, n_chains = hweight8(dev->mphy.antenna_mask), target_chains; u8 *eep = (u8 *)dev->mt76.eeprom.data; enum nl80211_band band = sband->band; + int delta = mt76_tx_power_nss_delta(n_chains); target_chains = mt7615_ext_pa_enabled(dev, band) ? 1 : n_chains; for (i = 0; i < sband->n_channels; i++) { @@ -283,21 +284,7 @@ mt7615_init_txpower(struct mt7615_dev *dev, target_power = max(target_power, eep[index]); } - target_power = DIV_ROUND_UP(target_power, 2); - switch (n_chains) { - case 4: - target_power += 6; - break; - case 3: - target_power += 4; - break; - case 2: - target_power += 3; - break; - default: - break; - } - + target_power = DIV_ROUND_UP(target_power + delta, 2); chan->max_power = min_t(int, chan->max_reg_power, target_power); chan->orig_mpwr = target_power; |