blob: 6a9cebe7f9961642a0514d053de5030163e14972 [file] [log] [blame]
developer699cda22022-12-17 15:21:57 +08001From e6b4dcb07b02fea725d11d364fabb0f801423edd Mon Sep 17 00:00:00 2001
developer30d39c22022-12-16 10:29:49 +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
developer699cda22022-12-17 15:21:57 +080022index 24efa28..a796289 100644
developer30d39c22022-12-16 10:29:49 +080023--- 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--
developer699cda22022-12-17 15:21:57 +0800422.36.1
developer30d39c22022-12-16 10:29:49 +080043