blob: 0296e72a392c12ebf0960677f19875cb032783ef [file] [log] [blame]
developer30d39c22022-12-16 10:29:49 +08001From ddc4b8bffa97ad1ec9ef0909f38429cd00a4875f Mon Sep 17 00:00:00 2001
2From: 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 24efa280..a7962893 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.25.1
43