mt76x2: fix avg_rssi estimation
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Wed, 2 May 2018 09:46:36 +0000 (11:46 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 4 May 2018 12:40:20 +0000 (15:40 +0300)
Add leftover filter coefficients in IIR rssi estimation

Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Acked-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt76/mt76x2_phy.c

index 038d1fe6c72670e3084a70fda6859cbdc5f20356..c1c38ca3330a0c62d8b4bdec33ee2853b7e283ab 100644 (file)
@@ -508,8 +508,10 @@ mt76x2_phy_update_channel_gain(struct mt76x2_dev *dev)
        u8 gain_delta;
        int low_gain;
 
-       dev->cal.avg_rssi[0] = (dev->cal.avg_rssi[0] * 15) / 16 + (rssi0 << 8);
-       dev->cal.avg_rssi[1] = (dev->cal.avg_rssi[1] * 15) / 16 + (rssi1 << 8);
+       dev->cal.avg_rssi[0] = (dev->cal.avg_rssi[0] * 15) / 16 +
+                              (rssi0 << 8) / 16;
+       dev->cal.avg_rssi[1] = (dev->cal.avg_rssi[1] * 15) / 16 +
+                              (rssi1 << 8) / 16;
        dev->cal.avg_rssi_all = (dev->cal.avg_rssi[0] +
                                 dev->cal.avg_rssi[1]) / 512;