501-ath9k-eeprom_endianess.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. - if (!ath9k_hw_use_flash(ah)) {
  16. - ath_dbg(common, EEPROM, "Read Magic = 0x%04X\n", magic);
  17. -
  18. - if (magic != AR5416_EEPROM_MAGIC) {
  19. - magic2 = swab16(magic);
  20. -
  21. - if (magic2 == AR5416_EEPROM_MAGIC) {
  22. - size = sizeof(struct ar5416_eeprom_def);
  23. - need_swap = true;
  24. - eepdata = (u16 *) (&ah->eeprom);
  25. -
  26. - for (addr = 0; addr < size / sizeof(u16); addr++) {
  27. - temp = swab16(*eepdata);
  28. - *eepdata = temp;
  29. - eepdata++;
  30. - }
  31. - } else {
  32. - ath_err(common,
  33. - "Invalid EEPROM Magic. Endianness mismatch.\n");
  34. - return -EINVAL;
  35. - }
  36. + if (swab16(magic) == AR5416_EEPROM_MAGIC &&
  37. + !(ah->ah_flags & AH_NO_EEP_SWAP)) {
  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. --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
  49. +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
  50. @@ -57,7 +57,7 @@ static bool ath9k_hw_4k_fill_eeprom(stru
  51. {
  52. struct ath_common *common = ath9k_hw_common(ah);
  53. - if (!ath9k_hw_use_flash(ah)) {
  54. + if (!(ah->ah_flags & AH_NO_EEP_SWAP)) {
  55. ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n");
  56. }
  57. --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  58. +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  59. @@ -60,7 +60,7 @@ static bool ath9k_hw_ar9287_fill_eeprom(
  60. {
  61. struct ath_common *common = ath9k_hw_common(ah);
  62. - if (!ath9k_hw_use_flash(ah)) {
  63. + if (!(ah->ah_flags & AH_NO_EEP_SWAP)) {
  64. ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n");
  65. }
  66. --- a/drivers/net/wireless/ath/ath9k/hw.h
  67. +++ b/drivers/net/wireless/ath/ath9k/hw.h
  68. @@ -739,6 +739,7 @@ enum ath_cal_list {
  69. #define AH_USE_EEPROM 0x1
  70. #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */
  71. #define AH_FASTCC 0x4
  72. +#define AH_NO_EEP_SWAP 0x8 /* Do not swap EEPROM data */
  73. struct ath_hw {
  74. struct ath_ops reg_ops;
  75. --- a/drivers/net/wireless/ath/ath9k/init.c
  76. +++ b/drivers/net/wireless/ath/ath9k/init.c
  77. @@ -613,6 +613,8 @@ static int ath9k_init_softc(u16 devid, s
  78. ah->is_clk_25mhz = pdata->is_clk_25mhz;
  79. ah->get_mac_revision = pdata->get_mac_revision;
  80. ah->external_reset = pdata->external_reset;
  81. + if (!pdata->endian_check)
  82. + ah->ah_flags |= AH_NO_EEP_SWAP;
  83. }
  84. common = ath9k_hw_common(ah);
  85. --- a/include/linux/ath9k_platform.h
  86. +++ b/include/linux/ath9k_platform.h
  87. @@ -31,6 +31,7 @@ struct ath9k_platform_data {
  88. u32 gpio_mask;
  89. u32 gpio_val;
  90. + bool endian_check;
  91. bool is_clk_25mhz;
  92. int (*get_mac_revision)(void);
  93. int (*external_reset)(void);