| 1 | --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c |
| 2 | +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c |
| 3 | @@ -262,7 +262,7 @@ static int ath9k_hw_def_check_eeprom(str |
| 4 | { |
| 5 | struct ar5416_eeprom_def *eep = &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 | @@ -272,27 +272,16 @@ 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 | + !(ah->ah_flags & AH_NO_EEP_SWAP)) { |
| 39 | + size = sizeof(struct ar5416_eeprom_def); |
| 40 | + need_swap = true; |
| 41 | + eepdata = (u16 *) (&ah->eeprom); |
| 42 | + |
| 43 | + for (addr = 0; addr < size / sizeof(u16); addr++) { |
| 44 | + temp = swab16(*eepdata); |
| 45 | + *eepdata = temp; |
| 46 | + eepdata++; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c |
| 51 | +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c |
| 52 | @@ -57,7 +57,7 @@ static bool ath9k_hw_4k_fill_eeprom(stru |
| 53 | { |
| 54 | struct ath_common *common = ath9k_hw_common(ah); |
| 55 | |
| 56 | - if (!ath9k_hw_use_flash(ah)) { |
| 57 | + if (!(ah->ah_flags & AH_NO_EEP_SWAP)) { |
| 58 | ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n"); |
| 59 | } |
| 60 | |
| 61 | --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c |
| 62 | +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c |
| 63 | @@ -60,7 +60,7 @@ static bool ath9k_hw_ar9287_fill_eeprom( |
| 64 | { |
| 65 | struct ath_common *common = ath9k_hw_common(ah); |
| 66 | |
| 67 | - if (!ath9k_hw_use_flash(ah)) { |
| 68 | + if (!(ah->ah_flags & AH_NO_EEP_SWAP)) { |
| 69 | ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n"); |
| 70 | } |
| 71 | |
| 72 | --- a/drivers/net/wireless/ath/ath9k/hw.h |
| 73 | +++ b/drivers/net/wireless/ath/ath9k/hw.h |
| 74 | @@ -705,6 +705,7 @@ enum ath_cal_list { |
| 75 | #define AH_USE_EEPROM 0x1 |
| 76 | #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */ |
| 77 | #define AH_FASTCC 0x4 |
| 78 | +#define AH_NO_EEP_SWAP 0x8 /* Do not swap EEPROM data */ |
| 79 | |
| 80 | struct ath_hw { |
| 81 | struct ath_ops reg_ops; |
| 82 | --- a/drivers/net/wireless/ath/ath9k/init.c |
| 83 | +++ b/drivers/net/wireless/ath/ath9k/init.c |
| 84 | @@ -591,6 +591,8 @@ static int ath9k_init_softc(u16 devid, s |
| 85 | ah->is_clk_25mhz = pdata->is_clk_25mhz; |
| 86 | ah->get_mac_revision = pdata->get_mac_revision; |
| 87 | ah->external_reset = pdata->external_reset; |
| 88 | + if (!pdata->endian_check) |
| 89 | + ah->ah_flags |= AH_NO_EEP_SWAP; |
| 90 | } |
| 91 | |
| 92 | common = ath9k_hw_common(ah); |
| 93 | --- a/include/linux/ath9k_platform.h |
| 94 | +++ b/include/linux/ath9k_platform.h |
| 95 | @@ -31,6 +31,7 @@ struct ath9k_platform_data { |
| 96 | u32 gpio_mask; |
| 97 | u32 gpio_val; |
| 98 | |
| 99 | + bool endian_check; |
| 100 | bool is_clk_25mhz; |
| 101 | int (*get_mac_revision)(void); |
| 102 | int (*external_reset)(void); |
| 103 | |