]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mt76: fix broken precal loading from MTD for mt7915
authorChristian Marangi <ansuelsmth@gmail.com>
Wed, 18 Oct 2023 13:09:37 +0000 (15:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:27:43 +0000 (15:27 -0800)
commit e874a79250b39447765ac13272b67ac36ccf2a75 upstream.

Commit 495184ac91bb ("mt76: mt7915: add support for applying
pre-calibration data") was fundamentally broken and never worked.

The idea (before NVMEM support) was to expand the MTD function and pass
an additional offset. For normal EEPROM load the offset would always be
0. For the purpose of precal loading, an offset was passed that was
internally the size of EEPROM, since precal data is right after the
EEPROM.

Problem is that the offset value passed is never handled and is actually
overwrite by

offset = be32_to_cpup(list);
ret = mtd_read(mtd, offset, len, &retlen, eep);

resulting in the passed offset value always ingnored. (and even passing
garbage data as precal as the start of the EEPROM is getting read)

Fix this by adding to the current offset value, the offset from DT to
correctly read the piece of data at the requested location.

Cc: stable@vger.kernel.org
Fixes: 495184ac91bb ("mt76: mt7915: add support for applying pre-calibration data")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/mediatek/mt76/eeprom.c

index 9bc8758573fcc8d63c72c66e41422adf83b4855b..0a88048b897680e9c0c689e8b28616ca19a1c9ee 100644 (file)
@@ -62,7 +62,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
                goto out_put_node;
        }
 
-       offset = be32_to_cpup(list);
+       offset += be32_to_cpup(list);
        ret = mtd_read(mtd, offset, len, &retlen, eep);
        put_mtd_device(mtd);
        if (mtd_is_bitflip(ret))