aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index 9a09cc8e7044..4cb64a0900bb 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -2892,7 +2892,6 @@ static bool ath9k_hw_AR9287_fill_eeprom(struct ath_hw *ah)
2892} 2892}
2893static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) 2893static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
2894{ 2894{
2895#define SIZE_EEPROM_87 (sizeof(struct ar9287_eeprom) / sizeof(u16))
2896 u32 sum = 0, el, integer; 2895 u32 sum = 0, el, integer;
2897 u16 temp, word, magic, magic2, *eepdata; 2896 u16 temp, word, magic, magic2, *eepdata;
2898 int i, addr; 2897 int i, addr;
@@ -2918,7 +2917,9 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
2918 need_swap = true; 2917 need_swap = true;
2919 eepdata = (u16 *)(&ah->eeprom); 2918 eepdata = (u16 *)(&ah->eeprom);
2920 2919
2921 for (addr = 0; addr < SIZE_EEPROM_87; addr++) { 2920 for (addr = 0;
2921 addr < sizeof(struct ar9287_eeprom) / sizeof(u16);
2922 addr++) {
2922 temp = swab16(*eepdata); 2923 temp = swab16(*eepdata);
2923 *eepdata = temp; 2924 *eepdata = temp;
2924 eepdata++; 2925 eepdata++;
@@ -2938,8 +2939,13 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
2938 else 2939 else
2939 el = ah->eeprom.map9287.baseEepHeader.length; 2940 el = ah->eeprom.map9287.baseEepHeader.length;
2940 2941
2942 if (el > sizeof(struct ar9287_eeprom))
2943 el = sizeof(struct ar9287_eeprom) / sizeof(u16);
2944 else
2945 el = el / sizeof(u16);
2946
2941 eepdata = (u16 *)(&ah->eeprom); 2947 eepdata = (u16 *)(&ah->eeprom);
2942 for (i = 0; i < min(el, SIZE_EEPROM_87); i++) 2948 for (i = 0; i < el; i++)
2943 sum ^= *eepdata++; 2949 sum ^= *eepdata++;
2944 2950
2945 if (need_swap) { 2951 if (need_swap) {
@@ -2990,7 +2996,6 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
2990 } 2996 }
2991 2997
2992 return 0; 2998 return 0;
2993#undef SIZE_EEPROM_87
2994} 2999}
2995 3000
2996static u32 ath9k_hw_AR9287_get_eeprom(struct ath_hw *ah, 3001static u32 ath9k_hw_AR9287_get_eeprom(struct ath_hw *ah,