556-ath9k-define-all-EEPROM-fields-in-Little-Endian-form.patch 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. From 7e1047f3cf8dcdb4825f3c785f7f708d07508096 Mon Sep 17 00:00:00 2001
  2. From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
  3. Date: Mon, 3 Oct 2016 00:29:13 +0200
  4. Subject: [v2 PATCH 7/7] ath9k: define all EEPROM fields in Little Endian format
  5. The ar9300_eeprom logic is already using only 8-bit (endian neutral),
  6. __le16 and __le32 fields to state explicitly how the values should be
  7. interpreted.
  8. All other EEPROM implementations (4k, 9287 and def) were using u16 and
  9. u32 fields with additional logic to swap the values (read from the
  10. original EEPROM) so they match the current CPUs endianness.
  11. The EEPROM format defaults to "all values are Little Endian", indicated
  12. by the absence of the AR5416_EEPMISC_BIG_ENDIAN in the u8 EEPMISC
  13. register. If we detect that the EEPROM indicates Big Endian mode
  14. (AR5416_EEPMISC_BIG_ENDIAN is set in the EEPMISC register) then we'll
  15. swap the values to convert them into Little Endian. This is done by
  16. activating the EEPMISC based logic in ath9k_hw_nvram_swap_data even if
  17. AH_NO_EEP_SWAP is set (this makes ath9k behave like the FreeBSD driver,
  18. which also does not have a flag to enable swapping based on the
  19. AR5416_EEPMISC_BIG_ENDIAN bit). Before this logic was only used to
  20. enable swapping when "current CPU endianness != EEPROM endianness".
  21. After changing all relevant fields to __le16 and __le32 sparse was used
  22. to check that all code which reads any of these fields uses
  23. le{16,32}_to_cpu.
  24. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
  25. ---
  26. drivers/net/wireless/ath/ath9k/eeprom.c | 27 ++-----
  27. drivers/net/wireless/ath/ath9k/eeprom.h | 75 ++++++++++--------
  28. drivers/net/wireless/ath/ath9k/eeprom_4k.c | 94 +++++++++-------------
  29. drivers/net/wireless/ath/ath9k/eeprom_9287.c | 98 ++++++++++-------------
  30. drivers/net/wireless/ath/ath9k/eeprom_def.c | 114 ++++++++++++---------------
  31. 5 files changed, 174 insertions(+), 234 deletions(-)
  32. --- a/drivers/net/wireless/ath/ath9k/eeprom.c
  33. +++ b/drivers/net/wireless/ath/ath9k/eeprom.c
  34. @@ -155,17 +155,10 @@ bool ath9k_hw_nvram_read(struct ath_hw *
  35. return ret;
  36. }
  37. -#ifdef __BIG_ENDIAN
  38. -#define EXPECTED_EEPMISC_ENDIAN AR5416_EEPMISC_BIG_ENDIAN
  39. -#else
  40. -#define EXPECTED_EEPMISC_ENDIAN 0
  41. -#endif
  42. -
  43. int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size)
  44. {
  45. u16 magic;
  46. u16 *eepdata;
  47. - u8 eepmisc;
  48. int i;
  49. bool needs_byteswap = false;
  50. struct ath_common *common = ath9k_hw_common(ah);
  51. @@ -203,25 +196,17 @@ int ath9k_hw_nvram_swap_data(struct ath_
  52. }
  53. }
  54. - *swap_needed = false;
  55. -
  56. - eepmisc = ah->eep_ops->get_eepmisc(ah);
  57. - if ((eepmisc & AR5416_EEPMISC_BIG_ENDIAN) != EXPECTED_EEPMISC_ENDIAN) {
  58. - if (ah->ah_flags & AH_NO_EEP_SWAP) {
  59. - ath_info(common,
  60. - "Ignoring endianness difference in eepmisc register.\n");
  61. - } else {
  62. - *swap_needed = true;
  63. - ath_dbg(common, EEPROM,
  64. - "EEPROM needs swapping according to the eepmisc register.\n");
  65. - }
  66. + if (ah->eep_ops->get_eepmisc(ah) & AR5416_EEPMISC_BIG_ENDIAN) {
  67. + *swap_needed = true;
  68. + ath_dbg(common, EEPROM,
  69. + "Big Endian EEPROM detected according to EEPMISC register.\n");
  70. + } else {
  71. + *swap_needed = false;
  72. }
  73. return 0;
  74. }
  75. -#undef EXPECTED_EEPMISC_VAL
  76. -
  77. bool ath9k_hw_nvram_validate_checksum(struct ath_hw *ah, int size)
  78. {
  79. u32 i, sum = 0;
  80. --- a/drivers/net/wireless/ath/ath9k/eeprom.h
  81. +++ b/drivers/net/wireless/ath/ath9k/eeprom.h
  82. @@ -23,6 +23,17 @@
  83. #include <net/cfg80211.h>
  84. #include "ar9003_eeprom.h"
  85. +/* helpers to swap EEPROM fields, which are stored as __le16 or __le32. Since
  86. + * we are 100% sure about it we __force these to u16/u32 for the swab calls to
  87. + * silence the sparse checks. These macros are used when we have a Big Endian
  88. + * EEPROM (according to AR5416_EEPMISC_BIG_ENDIAN) and need to convert the
  89. + * fields to __le16/__le32.
  90. + */
  91. +#define EEPROM_FIELD_SWAB16(field) \
  92. + (field = (__force __le16)swab16((__force u16)field))
  93. +#define EEPROM_FIELD_SWAB32(field) \
  94. + (field = (__force __le32)swab32((__force u32)field))
  95. +
  96. #ifdef __BIG_ENDIAN
  97. #define AR5416_EEPROM_MAGIC 0x5aa5
  98. #else
  99. @@ -270,19 +281,19 @@ enum ath9k_hal_freq_band {
  100. };
  101. struct base_eep_header {
  102. - u16 length;
  103. - u16 checksum;
  104. - u16 version;
  105. + __le16 length;
  106. + __le16 checksum;
  107. + __le16 version;
  108. u8 opCapFlags;
  109. u8 eepMisc;
  110. - u16 regDmn[2];
  111. + __le16 regDmn[2];
  112. u8 macAddr[6];
  113. u8 rxMask;
  114. u8 txMask;
  115. - u16 rfSilent;
  116. - u16 blueToothOptions;
  117. - u16 deviceCap;
  118. - u32 binBuildNumber;
  119. + __le16 rfSilent;
  120. + __le16 blueToothOptions;
  121. + __le16 deviceCap;
  122. + __le32 binBuildNumber;
  123. u8 deviceType;
  124. u8 pwdclkind;
  125. u8 fastClk5g;
  126. @@ -300,33 +311,33 @@ struct base_eep_header {
  127. } __packed;
  128. struct base_eep_header_4k {
  129. - u16 length;
  130. - u16 checksum;
  131. - u16 version;
  132. + __le16 length;
  133. + __le16 checksum;
  134. + __le16 version;
  135. u8 opCapFlags;
  136. u8 eepMisc;
  137. - u16 regDmn[2];
  138. + __le16 regDmn[2];
  139. u8 macAddr[6];
  140. u8 rxMask;
  141. u8 txMask;
  142. - u16 rfSilent;
  143. - u16 blueToothOptions;
  144. - u16 deviceCap;
  145. - u32 binBuildNumber;
  146. + __le16 rfSilent;
  147. + __le16 blueToothOptions;
  148. + __le16 deviceCap;
  149. + __le32 binBuildNumber;
  150. u8 deviceType;
  151. u8 txGainType;
  152. } __packed;
  153. struct spur_chan {
  154. - u16 spurChan;
  155. + __le16 spurChan;
  156. u8 spurRangeLow;
  157. u8 spurRangeHigh;
  158. } __packed;
  159. struct modal_eep_header {
  160. - u32 antCtrlChain[AR5416_MAX_CHAINS];
  161. - u32 antCtrlCommon;
  162. + __le32 antCtrlChain[AR5416_MAX_CHAINS];
  163. + __le32 antCtrlCommon;
  164. u8 antennaGainCh[AR5416_MAX_CHAINS];
  165. u8 switchSettling;
  166. u8 txRxAttenCh[AR5416_MAX_CHAINS];
  167. @@ -361,7 +372,7 @@ struct modal_eep_header {
  168. u8 db_ch1;
  169. u8 lna_ctl;
  170. u8 miscBits;
  171. - u16 xpaBiasLvlFreq[3];
  172. + __le16 xpaBiasLvlFreq[3];
  173. u8 futureModal[6];
  174. struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
  175. @@ -375,8 +386,8 @@ struct calDataPerFreqOpLoop {
  176. } __packed;
  177. struct modal_eep_4k_header {
  178. - u32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
  179. - u32 antCtrlCommon;
  180. + __le32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
  181. + __le32 antCtrlCommon;
  182. u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS];
  183. u8 switchSettling;
  184. u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS];
  185. @@ -440,19 +451,19 @@ struct modal_eep_4k_header {
  186. } __packed;
  187. struct base_eep_ar9287_header {
  188. - u16 length;
  189. - u16 checksum;
  190. - u16 version;
  191. + __le16 length;
  192. + __le16 checksum;
  193. + __le16 version;
  194. u8 opCapFlags;
  195. u8 eepMisc;
  196. - u16 regDmn[2];
  197. + __le16 regDmn[2];
  198. u8 macAddr[6];
  199. u8 rxMask;
  200. u8 txMask;
  201. - u16 rfSilent;
  202. - u16 blueToothOptions;
  203. - u16 deviceCap;
  204. - u32 binBuildNumber;
  205. + __le16 rfSilent;
  206. + __le16 blueToothOptions;
  207. + __le16 deviceCap;
  208. + __le32 binBuildNumber;
  209. u8 deviceType;
  210. u8 openLoopPwrCntl;
  211. int8_t pwrTableOffset;
  212. @@ -462,8 +473,8 @@ struct base_eep_ar9287_header {
  213. } __packed;
  214. struct modal_eep_ar9287_header {
  215. - u32 antCtrlChain[AR9287_MAX_CHAINS];
  216. - u32 antCtrlCommon;
  217. + __le32 antCtrlChain[AR9287_MAX_CHAINS];
  218. + __le32 antCtrlCommon;
  219. int8_t antennaGainCh[AR9287_MAX_CHAINS];
  220. u8 switchSettling;
  221. u8 txRxAttenCh[AR9287_MAX_CHAINS];
  222. --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
  223. +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
  224. @@ -20,7 +20,7 @@
  225. static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah)
  226. {
  227. - u16 version = ah->eeprom.map4k.baseEepHeader.version;
  228. + u16 version = le16_to_cpu(ah->eeprom.map4k.baseEepHeader.version);
  229. return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  230. AR5416_EEP_VER_MAJOR_SHIFT;
  231. @@ -28,7 +28,7 @@ static int ath9k_hw_4k_get_eeprom_ver(st
  232. static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah)
  233. {
  234. - u16 version = ah->eeprom.map4k.baseEepHeader.version;
  235. + u16 version = le16_to_cpu(ah->eeprom.map4k.baseEepHeader.version);
  236. return version & AR5416_EEP_VER_MINOR_MASK;
  237. }
  238. @@ -76,8 +76,8 @@ static bool ath9k_hw_4k_fill_eeprom(stru
  239. static u32 ath9k_dump_4k_modal_eeprom(char *buf, u32 len, u32 size,
  240. struct modal_eep_4k_header *modal_hdr)
  241. {
  242. - PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
  243. - PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
  244. + PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  245. + PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  246. PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
  247. PR_EEP("Switch Settle", modal_hdr->switchSettling);
  248. PR_EEP("Chain0 TxRxAtten", modal_hdr->txRxAttenCh[0]);
  249. @@ -132,6 +132,7 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
  250. {
  251. struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
  252. struct base_eep_header_4k *pBase = &eep->baseEepHeader;
  253. + u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
  254. if (!dump_base_hdr) {
  255. len += scnprintf(buf + len, size - len,
  256. @@ -143,10 +144,10 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
  257. PR_EEP("Major Version", ath9k_hw_4k_get_eeprom_ver(ah));
  258. PR_EEP("Minor Version", ath9k_hw_4k_get_eeprom_rev(ah));
  259. - PR_EEP("Checksum", pBase->checksum);
  260. - PR_EEP("Length", pBase->length);
  261. - PR_EEP("RegDomain1", pBase->regDmn[0]);
  262. - PR_EEP("RegDomain2", pBase->regDmn[1]);
  263. + PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
  264. + PR_EEP("Length", le16_to_cpu(pBase->length));
  265. + PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  266. + PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  267. PR_EEP("TX Mask", pBase->txMask);
  268. PR_EEP("RX Mask", pBase->rxMask);
  269. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
  270. @@ -160,9 +161,9 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
  271. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
  272. AR5416_OPFLAGS_N_5G_HT40));
  273. PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
  274. - PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
  275. - PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
  276. - PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
  277. + PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
  278. + PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
  279. + PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
  280. PR_EEP("TX Gain type", pBase->txGainType);
  281. len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
  282. @@ -194,54 +195,31 @@ static int ath9k_hw_4k_check_eeprom(stru
  283. return err;
  284. if (need_swap)
  285. - el = swab16(eep->baseEepHeader.length);
  286. + el = swab16((__force u16)eep->baseEepHeader.length);
  287. else
  288. - el = eep->baseEepHeader.length;
  289. + el = le16_to_cpu(eep->baseEepHeader.length);
  290. el = min(el / sizeof(u16), SIZE_EEPROM_4K);
  291. if (!ath9k_hw_nvram_validate_checksum(ah, el))
  292. return -EINVAL;
  293. if (need_swap) {
  294. - u32 integer;
  295. - u16 word;
  296. -
  297. - word = swab16(eep->baseEepHeader.length);
  298. - eep->baseEepHeader.length = word;
  299. -
  300. - word = swab16(eep->baseEepHeader.checksum);
  301. - eep->baseEepHeader.checksum = word;
  302. -
  303. - word = swab16(eep->baseEepHeader.version);
  304. - eep->baseEepHeader.version = word;
  305. -
  306. - word = swab16(eep->baseEepHeader.regDmn[0]);
  307. - eep->baseEepHeader.regDmn[0] = word;
  308. -
  309. - word = swab16(eep->baseEepHeader.regDmn[1]);
  310. - eep->baseEepHeader.regDmn[1] = word;
  311. -
  312. - word = swab16(eep->baseEepHeader.rfSilent);
  313. - eep->baseEepHeader.rfSilent = word;
  314. -
  315. - word = swab16(eep->baseEepHeader.blueToothOptions);
  316. - eep->baseEepHeader.blueToothOptions = word;
  317. -
  318. - word = swab16(eep->baseEepHeader.deviceCap);
  319. - eep->baseEepHeader.deviceCap = word;
  320. -
  321. - integer = swab32(eep->modalHeader.antCtrlCommon);
  322. - eep->modalHeader.antCtrlCommon = integer;
  323. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
  324. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
  325. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
  326. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
  327. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
  328. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
  329. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
  330. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
  331. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon);
  332. - for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++) {
  333. - integer = swab32(eep->modalHeader.antCtrlChain[i]);
  334. - eep->modalHeader.antCtrlChain[i] = integer;
  335. - }
  336. + for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++)
  337. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]);
  338. - for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  339. - word = swab16(eep->modalHeader.spurChans[i].spurChan);
  340. - eep->modalHeader.spurChans[i].spurChan = word;
  341. - }
  342. + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
  343. + EEPROM_FIELD_SWAB16(
  344. + eep->modalHeader.spurChans[i].spurChan);
  345. }
  346. if (!ath9k_hw_nvram_check_version(ah, AR5416_EEP_VER,
  347. @@ -270,13 +248,13 @@ static u32 ath9k_hw_4k_get_eeprom(struct
  348. case EEP_MAC_MSW:
  349. return get_unaligned_be16(pBase->macAddr + 4);
  350. case EEP_REG_0:
  351. - return pBase->regDmn[0];
  352. + return le16_to_cpu(pBase->regDmn[0]);
  353. case EEP_OP_CAP:
  354. - return pBase->deviceCap;
  355. + return le16_to_cpu(pBase->deviceCap);
  356. case EEP_OP_MODE:
  357. return pBase->opCapFlags;
  358. case EEP_RF_SILENT:
  359. - return pBase->rfSilent;
  360. + return le16_to_cpu(pBase->rfSilent);
  361. case EEP_OB_2:
  362. return pModal->ob_0;
  363. case EEP_DB_2:
  364. @@ -724,7 +702,7 @@ static void ath9k_hw_4k_set_gain(struct
  365. {
  366. ENABLE_REG_RMW_BUFFER(ah);
  367. REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0,
  368. - pModal->antCtrlChain[0], 0);
  369. + le32_to_cpu(pModal->antCtrlChain[0]), 0);
  370. REG_RMW(ah, AR_PHY_TIMING_CTRL4(0),
  371. SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
  372. @@ -790,7 +768,7 @@ static void ath9k_hw_4k_set_board_values
  373. pModal = &eep->modalHeader;
  374. txRxAttenLocal = 23;
  375. - REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
  376. + REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon));
  377. /* Single chain for 4K EEPROM*/
  378. ath9k_hw_4k_set_gain(ah, pModal, eep, txRxAttenLocal);
  379. @@ -1054,7 +1032,7 @@ static void ath9k_hw_4k_set_board_values
  380. static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
  381. {
  382. - return ah->eeprom.map4k.modalHeader.spurChans[i].spurChan;
  383. + return le16_to_cpu(ah->eeprom.map4k.modalHeader.spurChans[i].spurChan);
  384. }
  385. static u8 ath9k_hw_4k_get_eepmisc(struct ath_hw *ah)
  386. --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  387. +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  388. @@ -22,7 +22,7 @@
  389. static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
  390. {
  391. - u16 version = ah->eeprom.map9287.baseEepHeader.version;
  392. + u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version);
  393. return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  394. AR5416_EEP_VER_MAJOR_SHIFT;
  395. @@ -30,7 +30,7 @@ static int ath9k_hw_ar9287_get_eeprom_ve
  396. static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
  397. {
  398. - u16 version = ah->eeprom.map9287.baseEepHeader.version;
  399. + u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version);
  400. return version & AR5416_EEP_VER_MINOR_MASK;
  401. }
  402. @@ -79,9 +79,9 @@ static bool ath9k_hw_ar9287_fill_eeprom(
  403. static u32 ar9287_dump_modal_eeprom(char *buf, u32 len, u32 size,
  404. struct modal_eep_ar9287_header *modal_hdr)
  405. {
  406. - PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
  407. - PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]);
  408. - PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
  409. + PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  410. + PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
  411. + PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  412. PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
  413. PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]);
  414. PR_EEP("Switch Settle", modal_hdr->switchSettling);
  415. @@ -128,6 +128,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  416. {
  417. struct ar9287_eeprom *eep = &ah->eeprom.map9287;
  418. struct base_eep_ar9287_header *pBase = &eep->baseEepHeader;
  419. + u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
  420. if (!dump_base_hdr) {
  421. len += scnprintf(buf + len, size - len,
  422. @@ -139,10 +140,10 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  423. PR_EEP("Major Version", ath9k_hw_ar9287_get_eeprom_ver(ah));
  424. PR_EEP("Minor Version", ath9k_hw_ar9287_get_eeprom_rev(ah));
  425. - PR_EEP("Checksum", pBase->checksum);
  426. - PR_EEP("Length", pBase->length);
  427. - PR_EEP("RegDomain1", pBase->regDmn[0]);
  428. - PR_EEP("RegDomain2", pBase->regDmn[1]);
  429. + PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
  430. + PR_EEP("Length", le16_to_cpu(pBase->length));
  431. + PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  432. + PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  433. PR_EEP("TX Mask", pBase->txMask);
  434. PR_EEP("RX Mask", pBase->rxMask);
  435. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
  436. @@ -156,9 +157,9 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  437. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
  438. AR5416_OPFLAGS_N_5G_HT40));
  439. PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
  440. - PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
  441. - PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
  442. - PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
  443. + PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
  444. + PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
  445. + PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
  446. PR_EEP("Power Table Offset", pBase->pwrTableOffset);
  447. PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
  448. @@ -182,8 +183,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  449. static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah)
  450. {
  451. - u32 el, integer;
  452. - u16 word;
  453. + u32 el;
  454. int i, err;
  455. bool need_swap;
  456. struct ar9287_eeprom *eep = &ah->eeprom.map9287;
  457. @@ -193,51 +193,31 @@ static int ath9k_hw_ar9287_check_eeprom(
  458. return err;
  459. if (need_swap)
  460. - el = swab16(eep->baseEepHeader.length);
  461. + el = swab16((__force u16)eep->baseEepHeader.length);
  462. else
  463. - el = eep->baseEepHeader.length;
  464. + el = le16_to_cpu(eep->baseEepHeader.length);
  465. el = min(el / sizeof(u16), SIZE_EEPROM_AR9287);
  466. if (!ath9k_hw_nvram_validate_checksum(ah, el))
  467. return -EINVAL;
  468. if (need_swap) {
  469. - word = swab16(eep->baseEepHeader.length);
  470. - eep->baseEepHeader.length = word;
  471. -
  472. - word = swab16(eep->baseEepHeader.checksum);
  473. - eep->baseEepHeader.checksum = word;
  474. -
  475. - word = swab16(eep->baseEepHeader.version);
  476. - eep->baseEepHeader.version = word;
  477. -
  478. - word = swab16(eep->baseEepHeader.regDmn[0]);
  479. - eep->baseEepHeader.regDmn[0] = word;
  480. -
  481. - word = swab16(eep->baseEepHeader.regDmn[1]);
  482. - eep->baseEepHeader.regDmn[1] = word;
  483. -
  484. - word = swab16(eep->baseEepHeader.rfSilent);
  485. - eep->baseEepHeader.rfSilent = word;
  486. -
  487. - word = swab16(eep->baseEepHeader.blueToothOptions);
  488. - eep->baseEepHeader.blueToothOptions = word;
  489. -
  490. - word = swab16(eep->baseEepHeader.deviceCap);
  491. - eep->baseEepHeader.deviceCap = word;
  492. -
  493. - integer = swab32(eep->modalHeader.antCtrlCommon);
  494. - eep->modalHeader.antCtrlCommon = integer;
  495. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
  496. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
  497. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
  498. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
  499. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
  500. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
  501. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
  502. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
  503. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon);
  504. - for (i = 0; i < AR9287_MAX_CHAINS; i++) {
  505. - integer = swab32(eep->modalHeader.antCtrlChain[i]);
  506. - eep->modalHeader.antCtrlChain[i] = integer;
  507. - }
  508. + for (i = 0; i < AR9287_MAX_CHAINS; i++)
  509. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]);
  510. - for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  511. - word = swab16(eep->modalHeader.spurChans[i].spurChan);
  512. - eep->modalHeader.spurChans[i].spurChan = word;
  513. - }
  514. + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
  515. + EEPROM_FIELD_SWAB16(
  516. + eep->modalHeader.spurChans[i].spurChan);
  517. }
  518. if (!ath9k_hw_nvram_check_version(ah, AR9287_EEP_VER,
  519. @@ -267,13 +247,13 @@ static u32 ath9k_hw_ar9287_get_eeprom(st
  520. case EEP_MAC_MSW:
  521. return get_unaligned_be16(pBase->macAddr + 4);
  522. case EEP_REG_0:
  523. - return pBase->regDmn[0];
  524. + return le16_to_cpu(pBase->regDmn[0]);
  525. case EEP_OP_CAP:
  526. - return pBase->deviceCap;
  527. + return le16_to_cpu(pBase->deviceCap);
  528. case EEP_OP_MODE:
  529. return pBase->opCapFlags;
  530. case EEP_RF_SILENT:
  531. - return pBase->rfSilent;
  532. + return le16_to_cpu(pBase->rfSilent);
  533. case EEP_TX_MASK:
  534. return pBase->txMask;
  535. case EEP_RX_MASK:
  536. @@ -878,13 +858,13 @@ static void ath9k_hw_ar9287_set_board_va
  537. pModal = &eep->modalHeader;
  538. - REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
  539. + REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon));
  540. for (i = 0; i < AR9287_MAX_CHAINS; i++) {
  541. regChainOffset = i * 0x1000;
  542. REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
  543. - pModal->antCtrlChain[i]);
  544. + le32_to_cpu(pModal->antCtrlChain[i]));
  545. REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
  546. (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset)
  547. @@ -982,7 +962,9 @@ static void ath9k_hw_ar9287_set_board_va
  548. static u16 ath9k_hw_ar9287_get_spur_channel(struct ath_hw *ah,
  549. u16 i, bool is2GHz)
  550. {
  551. - return ah->eeprom.map9287.modalHeader.spurChans[i].spurChan;
  552. + __le16 spur_ch = ah->eeprom.map9287.modalHeader.spurChans[i].spurChan;
  553. +
  554. + return le16_to_cpu(spur_ch);
  555. }
  556. static u8 ath9k_hw_ar9287_get_eepmisc(struct ath_hw *ah)
  557. --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
  558. +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
  559. @@ -79,7 +79,7 @@ static void ath9k_olc_get_pdadcs(struct
  560. static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
  561. {
  562. - u16 version = ah->eeprom.def.baseEepHeader.version;
  563. + u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version);
  564. return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  565. AR5416_EEP_VER_MAJOR_SHIFT;
  566. @@ -87,7 +87,7 @@ static int ath9k_hw_def_get_eeprom_ver(s
  567. static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
  568. {
  569. - u16 version = ah->eeprom.def.baseEepHeader.version;
  570. + u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version);
  571. return version & AR5416_EEP_VER_MINOR_MASK;
  572. }
  573. @@ -135,10 +135,10 @@ static bool ath9k_hw_def_fill_eeprom(str
  574. static u32 ath9k_def_dump_modal_eeprom(char *buf, u32 len, u32 size,
  575. struct modal_eep_header *modal_hdr)
  576. {
  577. - PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
  578. - PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]);
  579. - PR_EEP("Chain2 Ant. Control", modal_hdr->antCtrlChain[2]);
  580. - PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
  581. + PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  582. + PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
  583. + PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
  584. + PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  585. PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
  586. PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]);
  587. PR_EEP("Chain2 Ant. Gain", modal_hdr->antennaGainCh[2]);
  588. @@ -194,9 +194,9 @@ static u32 ath9k_def_dump_modal_eeprom(c
  589. PR_EEP("Chain1 OutputBias", modal_hdr->ob_ch1);
  590. PR_EEP("Chain1 DriverBias", modal_hdr->db_ch1);
  591. PR_EEP("LNA Control", modal_hdr->lna_ctl);
  592. - PR_EEP("XPA Bias Freq0", modal_hdr->xpaBiasLvlFreq[0]);
  593. - PR_EEP("XPA Bias Freq1", modal_hdr->xpaBiasLvlFreq[1]);
  594. - PR_EEP("XPA Bias Freq2", modal_hdr->xpaBiasLvlFreq[2]);
  595. + PR_EEP("XPA Bias Freq0", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[0]));
  596. + PR_EEP("XPA Bias Freq1", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[1]));
  597. + PR_EEP("XPA Bias Freq2", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[2]));
  598. return len;
  599. }
  600. @@ -206,6 +206,7 @@ static u32 ath9k_hw_def_dump_eeprom(stru
  601. {
  602. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  603. struct base_eep_header *pBase = &eep->baseEepHeader;
  604. + u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
  605. if (!dump_base_hdr) {
  606. len += scnprintf(buf + len, size - len,
  607. @@ -221,10 +222,10 @@ static u32 ath9k_hw_def_dump_eeprom(stru
  608. PR_EEP("Major Version", ath9k_hw_def_get_eeprom_ver(ah));
  609. PR_EEP("Minor Version", ath9k_hw_def_get_eeprom_rev(ah));
  610. - PR_EEP("Checksum", pBase->checksum);
  611. - PR_EEP("Length", pBase->length);
  612. - PR_EEP("RegDomain1", pBase->regDmn[0]);
  613. - PR_EEP("RegDomain2", pBase->regDmn[1]);
  614. + PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
  615. + PR_EEP("Length", le16_to_cpu(pBase->length));
  616. + PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  617. + PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  618. PR_EEP("TX Mask", pBase->txMask);
  619. PR_EEP("RX Mask", pBase->rxMask);
  620. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
  621. @@ -238,9 +239,9 @@ static u32 ath9k_hw_def_dump_eeprom(stru
  622. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
  623. AR5416_OPFLAGS_N_5G_HT40));
  624. PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
  625. - PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
  626. - PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
  627. - PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
  628. + PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
  629. + PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
  630. + PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
  631. PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
  632. len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
  633. @@ -273,61 +274,40 @@ static int ath9k_hw_def_check_eeprom(str
  634. return err;
  635. if (need_swap)
  636. - el = swab16(eep->baseEepHeader.length);
  637. + el = swab16((__force u16)eep->baseEepHeader.length);
  638. else
  639. - el = eep->baseEepHeader.length;
  640. + el = le16_to_cpu(eep->baseEepHeader.length);
  641. el = min(el / sizeof(u16), SIZE_EEPROM_DEF);
  642. if (!ath9k_hw_nvram_validate_checksum(ah, el))
  643. return -EINVAL;
  644. if (need_swap) {
  645. - u32 integer, j;
  646. - u16 word;
  647. -
  648. - word = swab16(eep->baseEepHeader.length);
  649. - eep->baseEepHeader.length = word;
  650. -
  651. - word = swab16(eep->baseEepHeader.checksum);
  652. - eep->baseEepHeader.checksum = word;
  653. -
  654. - word = swab16(eep->baseEepHeader.version);
  655. - eep->baseEepHeader.version = word;
  656. -
  657. - word = swab16(eep->baseEepHeader.regDmn[0]);
  658. - eep->baseEepHeader.regDmn[0] = word;
  659. -
  660. - word = swab16(eep->baseEepHeader.regDmn[1]);
  661. - eep->baseEepHeader.regDmn[1] = word;
  662. -
  663. - word = swab16(eep->baseEepHeader.rfSilent);
  664. - eep->baseEepHeader.rfSilent = word;
  665. -
  666. - word = swab16(eep->baseEepHeader.blueToothOptions);
  667. - eep->baseEepHeader.blueToothOptions = word;
  668. + u32 j;
  669. - word = swab16(eep->baseEepHeader.deviceCap);
  670. - eep->baseEepHeader.deviceCap = word;
  671. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
  672. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
  673. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
  674. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
  675. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
  676. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
  677. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
  678. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
  679. for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) {
  680. struct modal_eep_header *pModal =
  681. &eep->modalHeader[j];
  682. - integer = swab32(pModal->antCtrlCommon);
  683. - pModal->antCtrlCommon = integer;
  684. + EEPROM_FIELD_SWAB32(pModal->antCtrlCommon);
  685. - for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  686. - integer = swab32(pModal->antCtrlChain[i]);
  687. - pModal->antCtrlChain[i] = integer;
  688. - }
  689. - for (i = 0; i < 3; i++) {
  690. - word = swab16(pModal->xpaBiasLvlFreq[i]);
  691. - pModal->xpaBiasLvlFreq[i] = word;
  692. - }
  693. + for (i = 0; i < AR5416_MAX_CHAINS; i++)
  694. + EEPROM_FIELD_SWAB32(pModal->antCtrlChain[i]);
  695. - for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  696. - word = swab16(pModal->spurChans[i].spurChan);
  697. - pModal->spurChans[i].spurChan = word;
  698. - }
  699. + for (i = 0; i < 3; i++)
  700. + EEPROM_FIELD_SWAB16(pModal->xpaBiasLvlFreq[i]);
  701. +
  702. + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
  703. + EEPROM_FIELD_SWAB16(
  704. + pModal->spurChans[i].spurChan);
  705. }
  706. }
  707. @@ -337,7 +317,7 @@ static int ath9k_hw_def_check_eeprom(str
  708. /* Enable fixup for AR_AN_TOP2 if necessary */
  709. if ((ah->hw_version.devid == AR9280_DEVID_PCI) &&
  710. - ((eep->baseEepHeader.version & 0xff) > 0x0a) &&
  711. + ((le16_to_cpu(eep->baseEepHeader.version) & 0xff) > 0x0a) &&
  712. (eep->baseEepHeader.pwdclkind == 0))
  713. ah->need_an_top2_fixup = true;
  714. @@ -370,13 +350,13 @@ static u32 ath9k_hw_def_get_eeprom(struc
  715. case EEP_MAC_MSW:
  716. return get_unaligned_be16(pBase->macAddr + 4);
  717. case EEP_REG_0:
  718. - return pBase->regDmn[0];
  719. + return le16_to_cpu(pBase->regDmn[0]);
  720. case EEP_OP_CAP:
  721. - return pBase->deviceCap;
  722. + return le16_to_cpu(pBase->deviceCap);
  723. case EEP_OP_MODE:
  724. return pBase->opCapFlags;
  725. case EEP_RF_SILENT:
  726. - return pBase->rfSilent;
  727. + return le16_to_cpu(pBase->rfSilent);
  728. case EEP_OB_5:
  729. return pModal[0].ob;
  730. case EEP_DB_5:
  731. @@ -490,11 +470,13 @@ static void ath9k_hw_def_set_board_value
  732. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  733. int i, regChainOffset;
  734. u8 txRxAttenLocal;
  735. + u32 antCtrlCommon;
  736. pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
  737. txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44;
  738. + antCtrlCommon = le32_to_cpu(pModal->antCtrlCommon);
  739. - REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon & 0xffff);
  740. + REG_WRITE(ah, AR_PHY_SWITCH_COM, antCtrlCommon & 0xffff);
  741. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  742. if (AR_SREV_9280(ah)) {
  743. @@ -508,7 +490,7 @@ static void ath9k_hw_def_set_board_value
  744. regChainOffset = i * 0x1000;
  745. REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
  746. - pModal->antCtrlChain[i]);
  747. + le32_to_cpu(pModal->antCtrlChain[i]));
  748. REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
  749. (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset) &
  750. @@ -655,7 +637,7 @@ static void ath9k_hw_def_set_board_value
  751. static void ath9k_hw_def_set_addac(struct ath_hw *ah,
  752. struct ath9k_channel *chan)
  753. {
  754. -#define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt])
  755. +#define XPA_LVL_FREQ(cnt) (le16_to_cpu(pModal->xpaBiasLvlFreq[cnt]))
  756. struct modal_eep_header *pModal;
  757. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  758. u8 biaslevel;
  759. @@ -1315,7 +1297,9 @@ static void ath9k_hw_def_set_txpower(str
  760. static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
  761. {
  762. - return ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan;
  763. + __le16 spch = ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan;
  764. +
  765. + return le16_to_cpu(spch);
  766. }
  767. static u8 ath9k_hw_def_get_eepmisc(struct ath_hw *ah)