wifi: mt76: mt7915: split mcu chan_mib array up
authorRyder Lee <ryder.lee@mediatek.com>
Sat, 3 Dec 2022 07:37:54 +0000 (15:37 +0800)
committerFelix Fietkau <nbd@nbd.name>
Fri, 9 Dec 2022 15:45:38 +0000 (16:45 +0100)
The current flow confuses coverity check that leads to false reporting,
so split the offs[] into two pieces according to chipset revision to
silence coverity tool.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

index b2652de..ca315af 100644 (file)
@@ -2974,38 +2974,42 @@ int mt7915_mcu_apply_tx_dpd(struct mt7915_phy *phy)
 
 int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch)
 {
-       /* strict order */
-       static const u32 offs[] = {
-               MIB_NON_WIFI_TIME,
-               MIB_TX_TIME,
-               MIB_RX_TIME,
-               MIB_OBSS_AIRTIME,
-               MIB_TXOP_INIT_COUNT,
-               /* v2 */
-               MIB_NON_WIFI_TIME_V2,
-               MIB_TX_TIME_V2,
-               MIB_RX_TIME_V2,
-               MIB_OBSS_AIRTIME_V2
-       };
        struct mt76_channel_state *state = phy->mt76->chan_state;
        struct mt76_channel_state *state_ts = &phy->state_ts;
        struct mt7915_dev *dev = phy->dev;
        struct mt7915_mcu_mib *res, req[5];
        struct sk_buff *skb;
-       int i, ret, start = 0, ofs = 20;
+       static const u32 *offs;
+       int i, ret, len, offs_cc;
        u64 cc_tx;
 
-       if (!is_mt7915(&dev->mt76)) {
-               start = 5;
-               ofs = 0;
+       /* strict order */
+       if (is_mt7915(&dev->mt76)) {
+               static const u32 chip_offs[] = {
+                       MIB_NON_WIFI_TIME,
+                       MIB_TX_TIME,
+                       MIB_RX_TIME,
+                       MIB_OBSS_AIRTIME,
+                       MIB_TXOP_INIT_COUNT,
+               };
+               len = ARRAY_SIZE(chip_offs);
+               offs = chip_offs;
+               offs_cc = 20;
+       } else {
+               static const u32 chip_offs[] = {
+                       MIB_NON_WIFI_TIME_V2,
+                       MIB_TX_TIME_V2,
+                       MIB_RX_TIME_V2,
+                       MIB_OBSS_AIRTIME_V2
+               };
+               len = ARRAY_SIZE(chip_offs);
+               offs = chip_offs;
+               offs_cc = 0;
        }
 
-       for (i = 0; i < 5; i++) {
+       for (i = 0; i < len; i++) {
                req[i].band = cpu_to_le32(phy->mt76->band_idx);
-               req[i].offs = cpu_to_le32(offs[i + start]);
-
-               if (!is_mt7915(&dev->mt76) && i == 3)
-                       break;
+               req[i].offs = cpu_to_le32(offs[i]);
        }
 
        ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(GET_MIB_INFO),
@@ -3013,7 +3017,7 @@ int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch)
        if (ret)
                return ret;
 
-       res = (struct mt7915_mcu_mib *)(skb->data + ofs);
+       res = (struct mt7915_mcu_mib *)(skb->data + offs_cc);
 
 #define __res_u64(s) le64_to_cpu(res[s].data)
        /* subtract Tx backoff time from Tx duration */