]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
mt76: unify firmware header between mt76x0 and mt76x2
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Sun, 9 Sep 2018 21:58:01 +0000 (23:58 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 19 Sep 2018 10:31:38 +0000 (12:31 +0200)
Move mt76x2_fw_header definition in mt76x02_mcu.h and remove
duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/mcu.c
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.h
drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c

index d757cde33f740699503217c88c1e14ec38f358a2..f5f619a3a196824932e42f71c21d48d61d722781 100644 (file)
@@ -73,17 +73,8 @@ mt76x0_mcu_calibrate(struct mt76x0_dev *dev, enum mcu_calibrate cal, u32 val)
        return mt76_mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true);
 }
 
-struct mt76_fw_header {
-       __le32 ilm_len;
-       __le32 dlm_len;
-       __le16 build_ver;
-       __le16 fw_ver;
-       u8 pad[4];
-       char build_time[16];
-};
-
 struct mt76_fw {
-       struct mt76_fw_header hdr;
+       struct mt76x02_fw_header hdr;
        u8 ivb[MT_MCU_IVB_SIZE];
        u8 ilm[];
 };
@@ -140,7 +131,7 @@ error:
 static int mt76x0_load_firmware(struct mt76x0_dev *dev)
 {
        const struct firmware *fw;
-       const struct mt76_fw_header *hdr;
+       const struct mt76x02_fw_header *hdr;
        int len, ret;
        u32 val;
 
@@ -157,7 +148,7 @@ static int mt76x0_load_firmware(struct mt76x0_dev *dev)
        if (!fw || !fw->data || fw->size < sizeof(*hdr))
                goto err_inv_fw;
 
-       hdr = (const struct mt76_fw_header *) fw->data;
+       hdr = (const struct mt76x02_fw_header *)fw->data;
 
        if (le32_to_cpu(hdr->ilm_len) <= MT_MCU_IVB_SIZE)
                goto err_inv_fw;
index 21181fddee98cb5f2b1773fcdbbc03fe87e66a3f..88b33b12ed4e8003b512ba0e26c3b785b315325d 100644 (file)
@@ -68,4 +68,21 @@ enum mcu_function {
        GET_FW_VERSION = 5,
 };
 
+struct mt76x02_fw_header {
+       __le32 ilm_len;
+       __le32 dlm_len;
+       __le16 build_ver;
+       __le16 fw_ver;
+       u8 pad[4];
+       char build_time[16];
+};
+
+struct mt76x02_patch_header {
+       char build_time[16];
+       char platform[4];
+       char hw_version[4];
+       char patch_version[4];
+       u8 pad[2];
+};
+
 #endif /* __MT76x02_MCU_H */
index d067ad48c3974788803e4e0c4a2129511da65f96..3fbaebe8b40823f14886169d2b90718b2f8c53f0 100644 (file)
@@ -104,7 +104,7 @@ static int
 mt76pci_load_rom_patch(struct mt76x2_dev *dev)
 {
        const struct firmware *fw = NULL;
-       struct mt76x2_patch_header *hdr;
+       struct mt76x02_patch_header *hdr;
        bool rom_protect = !is_mt7612(dev);
        int len, ret = 0;
        __le32 *cur;
@@ -139,7 +139,7 @@ mt76pci_load_rom_patch(struct mt76x2_dev *dev)
                goto out;
        }
 
-       hdr = (struct mt76x2_patch_header *) fw->data;
+       hdr = (struct mt76x02_patch_header *)fw->data;
        dev_info(dev->mt76.dev, "ROM patch build: %.15s\n", hdr->build_time);
 
        mt76_wr(dev, MT_MCU_PCIE_REMAP_BASE4, MT_MCU_ROM_PATCH_OFFSET);
@@ -170,7 +170,7 @@ static int
 mt76pci_load_firmware(struct mt76x2_dev *dev)
 {
        const struct firmware *fw;
-       const struct mt76x2_fw_header *hdr;
+       const struct mt76x02_fw_header *hdr;
        int len, ret;
        __le32 *cur;
        u32 offset, val;
@@ -182,7 +182,7 @@ mt76pci_load_firmware(struct mt76x2_dev *dev)
        if (!fw || !fw->data || fw->size < sizeof(*hdr))
                goto error;
 
-       hdr = (const struct mt76x2_fw_header *) fw->data;
+       hdr = (const struct mt76x02_fw_header *)fw->data;
 
        len = sizeof(*hdr);
        len += le32_to_cpu(hdr->ilm_len);
index 564bcac274019318978cf8f443e6051ea34129b7..c5da3293dafdb373febb5c79d62cae6fe4e61212 100644 (file)
@@ -101,23 +101,6 @@ struct mt76x2_tssi_comp {
        u8 offset1;
 } __packed __aligned(4);
 
-struct mt76x2_fw_header {
-       __le32 ilm_len;
-       __le32 dlm_len;
-       __le16 build_ver;
-       __le16 fw_ver;
-       u8 pad[4];
-       char build_time[16];
-};
-
-struct mt76x2_patch_header {
-       char build_time[16];
-       char platform[4];
-       char hw_version[4];
-       char patch_version[4];
-       u8 pad[2];
-};
-
 int mt76x2_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type,
                         u32 param);
 int mt76x2_mcu_tssi_comp(struct mt76x2_dev *dev, struct mt76x2_tssi_comp *tssi_data);
index e93123e4a3952f02d19d9c33f53f7d4595467a94..412e8f4660615b0d0867af5ab4dc55553d521bea 100644 (file)
@@ -236,7 +236,7 @@ static void mt76x2u_mcu_reset_wmt(struct mt76x2_dev *dev)
 static int mt76x2u_mcu_load_rom_patch(struct mt76x2_dev *dev)
 {
        bool rom_protect = !is_mt7612(dev);
-       struct mt76x2_patch_header *hdr;
+       struct mt76x02_patch_header *hdr;
        u32 val, patch_mask, patch_reg;
        const struct firmware *fw;
        int err;
@@ -271,7 +271,7 @@ static int mt76x2u_mcu_load_rom_patch(struct mt76x2_dev *dev)
                goto out;
        }
 
-       hdr = (struct mt76x2_patch_header *)fw->data;
+       hdr = (struct mt76x02_patch_header *)fw->data;
        dev_info(dev->mt76.dev, "ROM patch build: %.15s\n", hdr->build_time);
 
        /* enable USB_DMA_CFG */
@@ -323,7 +323,7 @@ out:
 static int mt76x2u_mcu_load_firmware(struct mt76x2_dev *dev)
 {
        u32 val, dlm_offset = MT76U_MCU_DLM_OFFSET;
-       const struct mt76x2_fw_header *hdr;
+       const struct mt76x02_fw_header *hdr;
        int err, len, ilm_len, dlm_len;
        const struct firmware *fw;
 
@@ -336,7 +336,7 @@ static int mt76x2u_mcu_load_firmware(struct mt76x2_dev *dev)
                goto out;
        }
 
-       hdr = (const struct mt76x2_fw_header *)fw->data;
+       hdr = (const struct mt76x02_fw_header *)fw->data;
        ilm_len = le32_to_cpu(hdr->ilm_len);
        dlm_len = le32_to_cpu(hdr->dlm_len);
        len = sizeof(*hdr) + ilm_len + dlm_len;