blob: 7bbd01d75b5341946e05b3e0513320a6c88a72d2 [file] [log] [blame]
developerefb40c12022-12-21 18:05:47 +08001From 6d47538ac0b3e34f8cda287e9666fc15842f1d0b Mon Sep 17 00:00:00 2001
developer2aa1e642022-12-19 11:33:22 +08002From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Thu, 8 Dec 2022 15:54:19 +0800
4Subject: [PATCH 6/6] wifi: mt76: mt7915: add chip id condition in
5 mt7915_check_eeprom()
6
7When flash mode is enabled, and the eeprom data in the flash is not for
8the current chipset, it'll still be checked valid, and the default
9eeprom bin won't be loaded.
10(e.g., mt7915 NIC inserted with mt7916 eeprom data in the flash.)
11
12Fix this kind of case by adding chip id into consideration in
13mt7915_check_eeprom().
14
15Reported-by: Cheng-Ji Li <cheng-ji.li@mediatek.com>
16Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
17---
18 mt7915/eeprom.c | 5 ++++-
19 1 file changed, 4 insertions(+), 1 deletion(-)
20
21diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
22index 24efa28..a796289 100644
23--- a/mt7915/eeprom.c
24+++ b/mt7915/eeprom.c
25@@ -33,11 +33,14 @@ static int mt7915_check_eeprom(struct mt7915_dev *dev)
26 u8 *eeprom = dev->mt76.eeprom.data;
27 u16 val = get_unaligned_le16(eeprom);
28
29+#define CHECK_EEPROM_ERR(match) (match ? 0 : -EINVAL)
30 switch (val) {
31 case 0x7915:
32+ return CHECK_EEPROM_ERR(is_mt7915(&dev->mt76));
33 case 0x7916:
34+ return CHECK_EEPROM_ERR(is_mt7916(&dev->mt76));
35 case 0x7986:
36- return 0;
37+ return CHECK_EEPROM_ERR(is_mt7986(&dev->mt76));
38 default:
39 return -EINVAL;
40 }
41--
422.36.1
43