adds eeprom endianess check to ath9k
[openwrt/openwrt.git] / package / mac80211 / patches / 999-ath9k.patch
1 --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
2 +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
3 @@ -267,7 +267,7 @@ static int ath9k_hw_def_check_eeprom(str
4 struct ar5416_eeprom_def *eep =
5 (struct ar5416_eeprom_def *) &ah->eeprom.def;
6 struct ath_common *common = ath9k_hw_common(ah);
7 - u16 *eepdata, temp, magic, magic2;
8 + u16 *eepdata, temp, magic;
9 u32 sum = 0, el;
10 bool need_swap = false;
11 int i, addr, size;
12 @@ -277,27 +277,15 @@ static int ath9k_hw_def_check_eeprom(str
13 return false;
14 }
15
16 - if (!ath9k_hw_use_flash(ah)) {
17 - ath_dbg(common, EEPROM, "Read Magic = 0x%04X\n", magic);
18 -
19 - if (magic != AR5416_EEPROM_MAGIC) {
20 - magic2 = swab16(magic);
21 -
22 - if (magic2 == AR5416_EEPROM_MAGIC) {
23 - size = sizeof(struct ar5416_eeprom_def);
24 - need_swap = true;
25 - eepdata = (u16 *) (&ah->eeprom);
26 -
27 - for (addr = 0; addr < size / sizeof(u16); addr++) {
28 - temp = swab16(*eepdata);
29 - *eepdata = temp;
30 - eepdata++;
31 - }
32 - } else {
33 - ath_err(common,
34 - "Invalid EEPROM Magic. Endianness mismatch.\n");
35 - return -EINVAL;
36 - }
37 + if (swab16(magic) == AR5416_EEPROM_MAGIC) {
38 + size = sizeof(struct ar5416_eeprom_def);
39 + need_swap = true;
40 + eepdata = (u16 *) (&ah->eeprom);
41 +
42 + for (addr = 0; addr < size / sizeof(u16); addr++) {
43 + temp = swab16(*eepdata);
44 + *eepdata = temp;
45 + eepdata++;
46 }
47 }
48