]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mt76: fix setting chan->max_power
authorFelix Fietkau <nbd@nbd.name>
Fri, 31 May 2019 20:03:11 +0000 (22:03 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 27 Jun 2019 10:58:13 +0000 (12:58 +0200)
When setting chan->max_power after registering the wiphy, chan->max_reg_power
needs to be used as a limit

Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7603/init.c
drivers/net/wireless/mediatek/mt76/mt76x0/init.c
drivers/net/wireless/mediatek/mt76/mt76x2/init.c

index 43baad7fd0829a9adaa1f239f9e78a58722a7e5e..f655091d106b4e5698dadfa1dd9dd1cddbf22ec3 100644 (file)
@@ -494,7 +494,7 @@ mt7603_init_txpower(struct mt7603_dev *dev,
 
        for (i = 0; i < sband->n_channels; i++) {
                chan = &sband->channels[i];
-               chan->max_power = target_power;
+               chan->max_power = min_t(int, chan->max_reg_power, target_power);
                chan->orig_mpwr = target_power;
        }
 }
index 57e46d57b44948f18583a894984e5e5bee995650..d67401f895ca1969512836417914e8737c6196e8 100644 (file)
@@ -279,8 +279,9 @@ mt76x0_init_txpower(struct mt76x02_dev *dev,
                mt76x0_get_tx_power_per_rate(dev, chan, &t);
                mt76x0_get_power_info(dev, chan, &tp);
 
-               chan->max_power = (mt76x02_get_max_rate_power(&t) + tp) / 2;
-               chan->orig_mpwr = chan->max_power;
+               chan->orig_mpwr = (mt76x02_get_max_rate_power(&t) + tp) / 2;
+               chan->max_power = min_t(int, chan->max_reg_power,
+                                       chan->orig_mpwr);
        }
 }
 
index c6078e90ca4340961bcee4259de33c787bd103a6..97c3543eed8ab03eb3f29d8169413b70cfece2f8 100644 (file)
@@ -173,13 +173,14 @@ void mt76x2_init_txpower(struct mt76x02_dev *dev,
                mt76x2_get_power_info(dev, &txp, chan);
                mt76x2_get_rate_power(dev, &t, chan);
 
-               chan->max_power = mt76x02_get_max_rate_power(&t) +
+               chan->orig_mpwr = mt76x02_get_max_rate_power(&t) +
                                  txp.target_power;
-               chan->max_power = DIV_ROUND_UP(chan->max_power, 2);
+               chan->orig_mpwr = DIV_ROUND_UP(chan->orig_mpwr, 2);
 
                /* convert to combined output power on 2x2 devices */
-               chan->max_power += 3;
-               chan->orig_mpwr = chan->max_power;
+               chan->orig_mpwr += 3;
+               chan->max_power = min_t(int, chan->max_reg_power,
+                                       chan->orig_mpwr);
        }
 }
 EXPORT_SYMBOL_GPL(mt76x2_init_txpower);