mt76: mt7915: rely on mt76_connac_mcu_init_download
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 24 Dec 2021 10:58:08 +0000 (11:58 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 3 Feb 2022 12:57:58 +0000 (13:57 +0100)
Rely on mt76_connac_mcu_init_download routine in mt7915 driver and
remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

index efd0519..2b647c1 100644 (file)
@@ -62,8 +62,8 @@ int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len,
        };
        int cmd;
 
-       if (is_mt7921(dev) &&
-           (req.addr == cpu_to_le32(MCU_PATCH_ADDRESS) || addr == 0x900000))
+       if ((!is_connac_v1(dev) && addr == MCU_PATCH_ADDRESS) ||
+           (is_mt7921(dev) && addr == 0x900000))
                cmd = MCU_CMD(PATCH_START_REQ);
        else
                cmd = MCU_CMD(TARGET_ADDRESS_LEN_REQ);
index 3eaf230..3f4b045 100644 (file)
@@ -1957,28 +1957,6 @@ static int mt7915_driver_own(struct mt7915_dev *dev, u8 band)
        return 0;
 }
 
-static int mt7915_mcu_init_download(struct mt7915_dev *dev, u32 addr,
-                                   u32 len, u32 mode)
-{
-       struct {
-               __le32 addr;
-               __le32 len;
-               __le32 mode;
-       } req = {
-               .addr = cpu_to_le32(addr),
-               .len = cpu_to_le32(len),
-               .mode = cpu_to_le32(mode),
-       };
-       int attr;
-
-       if (req.addr == cpu_to_le32(MCU_PATCH_ADDRESS))
-               attr = MCU_CMD(PATCH_START_REQ);
-       else
-               attr = MCU_CMD(TARGET_ADDRESS_LEN_REQ);
-
-       return mt76_mcu_send_msg(&dev->mt76, attr, &req, sizeof(req), true);
-}
-
 static int mt7915_load_patch(struct mt7915_dev *dev)
 {
        const struct mt7915_patch_hdr *hdr;
@@ -2030,8 +2008,8 @@ static int mt7915_load_patch(struct mt7915_dev *dev)
                len = be32_to_cpu(sec->info.len);
                dl = fw->data + be32_to_cpu(sec->offs);
 
-               ret = mt7915_mcu_init_download(dev, addr, len,
-                                              DL_MODE_NEED_RSP);
+               ret = mt76_connac_mcu_init_download(&dev->mt76, addr, len,
+                                                   DL_MODE_NEED_RSP);
                if (ret) {
                        dev_err(dev->mt76.dev, "Download request failed\n");
                        goto out;
@@ -2100,7 +2078,8 @@ mt7915_mcu_send_ram_firmware(struct mt7915_dev *dev,
                if (region->feature_set & FW_FEATURE_OVERRIDE_ADDR)
                        override = addr;
 
-               err = mt7915_mcu_init_download(dev, addr, len, mode);
+               err = mt76_connac_mcu_init_download(&dev->mt76, addr, len,
+                                                   mode);
                if (err) {
                        dev_err(dev->mt76.dev, "Download request failed\n");
                        return err;