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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  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. -
  324. - for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++) {
  325. - integer = swab32(eep->modalHeader.antCtrlChain[i]);
  326. - eep->modalHeader.antCtrlChain[i] = integer;
  327. - }
  328. -
  329. - for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  330. - word = swab16(eep->modalHeader.spurChans[i].spurChan);
  331. - eep->modalHeader.spurChans[i].spurChan = word;
  332. - }
  333. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
  334. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
  335. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
  336. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
  337. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
  338. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
  339. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
  340. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
  341. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon);
  342. +
  343. + for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++)
  344. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]);
  345. +
  346. + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
  347. + EEPROM_FIELD_SWAB16(
  348. + eep->modalHeader.spurChans[i].spurChan);
  349. }
  350. if (!ath9k_hw_nvram_check_version(ah, AR5416_EEP_VER,
  351. @@ -270,13 +248,13 @@ static u32 ath9k_hw_4k_get_eeprom(struct
  352. case EEP_MAC_MSW:
  353. return get_unaligned_be16(pBase->macAddr + 4);
  354. case EEP_REG_0:
  355. - return pBase->regDmn[0];
  356. + return le16_to_cpu(pBase->regDmn[0]);
  357. case EEP_OP_CAP:
  358. - return pBase->deviceCap;
  359. + return le16_to_cpu(pBase->deviceCap);
  360. case EEP_OP_MODE:
  361. return pBase->opCapFlags;
  362. case EEP_RF_SILENT:
  363. - return pBase->rfSilent;
  364. + return le16_to_cpu(pBase->rfSilent);
  365. case EEP_OB_2:
  366. return pModal->ob_0;
  367. case EEP_DB_2:
  368. @@ -724,7 +702,7 @@ static void ath9k_hw_4k_set_gain(struct
  369. {
  370. ENABLE_REG_RMW_BUFFER(ah);
  371. REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0,
  372. - pModal->antCtrlChain[0], 0);
  373. + le32_to_cpu(pModal->antCtrlChain[0]), 0);
  374. REG_RMW(ah, AR_PHY_TIMING_CTRL4(0),
  375. SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
  376. @@ -790,7 +768,7 @@ static void ath9k_hw_4k_set_board_values
  377. pModal = &eep->modalHeader;
  378. txRxAttenLocal = 23;
  379. - REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
  380. + REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon));
  381. /* Single chain for 4K EEPROM*/
  382. ath9k_hw_4k_set_gain(ah, pModal, eep, txRxAttenLocal);
  383. @@ -1054,7 +1032,7 @@ static void ath9k_hw_4k_set_board_values
  384. static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
  385. {
  386. - return ah->eeprom.map4k.modalHeader.spurChans[i].spurChan;
  387. + return le16_to_cpu(ah->eeprom.map4k.modalHeader.spurChans[i].spurChan);
  388. }
  389. static u8 ath9k_hw_4k_get_eepmisc(struct ath_hw *ah)
  390. --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  391. +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  392. @@ -22,7 +22,7 @@
  393. static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
  394. {
  395. - u16 version = ah->eeprom.map9287.baseEepHeader.version;
  396. + u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version);
  397. return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  398. AR5416_EEP_VER_MAJOR_SHIFT;
  399. @@ -30,7 +30,7 @@ static int ath9k_hw_ar9287_get_eeprom_ve
  400. static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
  401. {
  402. - u16 version = ah->eeprom.map9287.baseEepHeader.version;
  403. + u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version);
  404. return version & AR5416_EEP_VER_MINOR_MASK;
  405. }
  406. @@ -79,9 +79,9 @@ static bool ath9k_hw_ar9287_fill_eeprom(
  407. static u32 ar9287_dump_modal_eeprom(char *buf, u32 len, u32 size,
  408. struct modal_eep_ar9287_header *modal_hdr)
  409. {
  410. - PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
  411. - PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]);
  412. - PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
  413. + PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  414. + PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
  415. + PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  416. PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
  417. PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]);
  418. PR_EEP("Switch Settle", modal_hdr->switchSettling);
  419. @@ -128,6 +128,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  420. {
  421. struct ar9287_eeprom *eep = &ah->eeprom.map9287;
  422. struct base_eep_ar9287_header *pBase = &eep->baseEepHeader;
  423. + u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
  424. if (!dump_base_hdr) {
  425. len += scnprintf(buf + len, size - len,
  426. @@ -139,10 +140,10 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  427. PR_EEP("Major Version", ath9k_hw_ar9287_get_eeprom_ver(ah));
  428. PR_EEP("Minor Version", ath9k_hw_ar9287_get_eeprom_rev(ah));
  429. - PR_EEP("Checksum", pBase->checksum);
  430. - PR_EEP("Length", pBase->length);
  431. - PR_EEP("RegDomain1", pBase->regDmn[0]);
  432. - PR_EEP("RegDomain2", pBase->regDmn[1]);
  433. + PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
  434. + PR_EEP("Length", le16_to_cpu(pBase->length));
  435. + PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  436. + PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  437. PR_EEP("TX Mask", pBase->txMask);
  438. PR_EEP("RX Mask", pBase->rxMask);
  439. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
  440. @@ -156,9 +157,9 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  441. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
  442. AR5416_OPFLAGS_N_5G_HT40));
  443. PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
  444. - PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
  445. - PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
  446. - PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
  447. + PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
  448. + PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
  449. + PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
  450. PR_EEP("Power Table Offset", pBase->pwrTableOffset);
  451. PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
  452. @@ -182,8 +183,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  453. static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah)
  454. {
  455. - u32 el, integer;
  456. - u16 word;
  457. + u32 el;
  458. int i, err;
  459. bool need_swap;
  460. struct ar9287_eeprom *eep = &ah->eeprom.map9287;
  461. @@ -193,51 +193,31 @@ static int ath9k_hw_ar9287_check_eeprom(
  462. return err;
  463. if (need_swap)
  464. - el = swab16(eep->baseEepHeader.length);
  465. + el = swab16((__force u16)eep->baseEepHeader.length);
  466. else
  467. - el = eep->baseEepHeader.length;
  468. + el = le16_to_cpu(eep->baseEepHeader.length);
  469. el = min(el / sizeof(u16), SIZE_EEPROM_AR9287);
  470. if (!ath9k_hw_nvram_validate_checksum(ah, el))
  471. return -EINVAL;
  472. if (need_swap) {
  473. - word = swab16(eep->baseEepHeader.length);
  474. - eep->baseEepHeader.length = word;
  475. -
  476. - word = swab16(eep->baseEepHeader.checksum);
  477. - eep->baseEepHeader.checksum = word;
  478. -
  479. - word = swab16(eep->baseEepHeader.version);
  480. - eep->baseEepHeader.version = word;
  481. -
  482. - word = swab16(eep->baseEepHeader.regDmn[0]);
  483. - eep->baseEepHeader.regDmn[0] = word;
  484. -
  485. - word = swab16(eep->baseEepHeader.regDmn[1]);
  486. - eep->baseEepHeader.regDmn[1] = word;
  487. -
  488. - word = swab16(eep->baseEepHeader.rfSilent);
  489. - eep->baseEepHeader.rfSilent = word;
  490. -
  491. - word = swab16(eep->baseEepHeader.blueToothOptions);
  492. - eep->baseEepHeader.blueToothOptions = word;
  493. -
  494. - word = swab16(eep->baseEepHeader.deviceCap);
  495. - eep->baseEepHeader.deviceCap = word;
  496. -
  497. - integer = swab32(eep->modalHeader.antCtrlCommon);
  498. - eep->modalHeader.antCtrlCommon = integer;
  499. -
  500. - for (i = 0; i < AR9287_MAX_CHAINS; i++) {
  501. - integer = swab32(eep->modalHeader.antCtrlChain[i]);
  502. - eep->modalHeader.antCtrlChain[i] = integer;
  503. - }
  504. -
  505. - for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  506. - word = swab16(eep->modalHeader.spurChans[i].spurChan);
  507. - eep->modalHeader.spurChans[i].spurChan = word;
  508. - }
  509. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
  510. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
  511. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
  512. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
  513. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
  514. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
  515. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
  516. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
  517. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon);
  518. +
  519. + for (i = 0; i < AR9287_MAX_CHAINS; i++)
  520. + EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]);
  521. +
  522. + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
  523. + EEPROM_FIELD_SWAB16(
  524. + eep->modalHeader.spurChans[i].spurChan);
  525. }
  526. if (!ath9k_hw_nvram_check_version(ah, AR9287_EEP_VER,
  527. @@ -267,13 +247,13 @@ static u32 ath9k_hw_ar9287_get_eeprom(st
  528. case EEP_MAC_MSW:
  529. return get_unaligned_be16(pBase->macAddr + 4);
  530. case EEP_REG_0:
  531. - return pBase->regDmn[0];
  532. + return le16_to_cpu(pBase->regDmn[0]);
  533. case EEP_OP_CAP:
  534. - return pBase->deviceCap;
  535. + return le16_to_cpu(pBase->deviceCap);
  536. case EEP_OP_MODE:
  537. return pBase->opCapFlags;
  538. case EEP_RF_SILENT:
  539. - return pBase->rfSilent;
  540. + return le16_to_cpu(pBase->rfSilent);
  541. case EEP_TX_MASK:
  542. return pBase->txMask;
  543. case EEP_RX_MASK:
  544. @@ -878,13 +858,13 @@ static void ath9k_hw_ar9287_set_board_va
  545. pModal = &eep->modalHeader;
  546. - REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
  547. + REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon));
  548. for (i = 0; i < AR9287_MAX_CHAINS; i++) {
  549. regChainOffset = i * 0x1000;
  550. REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
  551. - pModal->antCtrlChain[i]);
  552. + le32_to_cpu(pModal->antCtrlChain[i]));
  553. REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
  554. (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset)
  555. @@ -982,7 +962,9 @@ static void ath9k_hw_ar9287_set_board_va
  556. static u16 ath9k_hw_ar9287_get_spur_channel(struct ath_hw *ah,
  557. u16 i, bool is2GHz)
  558. {
  559. - return ah->eeprom.map9287.modalHeader.spurChans[i].spurChan;
  560. + __le16 spur_ch = ah->eeprom.map9287.modalHeader.spurChans[i].spurChan;
  561. +
  562. + return le16_to_cpu(spur_ch);
  563. }
  564. static u8 ath9k_hw_ar9287_get_eepmisc(struct ath_hw *ah)
  565. --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
  566. +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
  567. @@ -79,7 +79,7 @@ static void ath9k_olc_get_pdadcs(struct
  568. static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
  569. {
  570. - u16 version = ah->eeprom.def.baseEepHeader.version;
  571. + u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version);
  572. return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  573. AR5416_EEP_VER_MAJOR_SHIFT;
  574. @@ -87,7 +87,7 @@ static int ath9k_hw_def_get_eeprom_ver(s
  575. static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
  576. {
  577. - u16 version = ah->eeprom.def.baseEepHeader.version;
  578. + u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version);
  579. return version & AR5416_EEP_VER_MINOR_MASK;
  580. }
  581. @@ -135,10 +135,10 @@ static bool ath9k_hw_def_fill_eeprom(str
  582. static u32 ath9k_def_dump_modal_eeprom(char *buf, u32 len, u32 size,
  583. struct modal_eep_header *modal_hdr)
  584. {
  585. - PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
  586. - PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]);
  587. - PR_EEP("Chain2 Ant. Control", modal_hdr->antCtrlChain[2]);
  588. - PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
  589. + PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  590. + PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
  591. + PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
  592. + PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  593. PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
  594. PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]);
  595. PR_EEP("Chain2 Ant. Gain", modal_hdr->antennaGainCh[2]);
  596. @@ -194,9 +194,9 @@ static u32 ath9k_def_dump_modal_eeprom(c
  597. PR_EEP("Chain1 OutputBias", modal_hdr->ob_ch1);
  598. PR_EEP("Chain1 DriverBias", modal_hdr->db_ch1);
  599. PR_EEP("LNA Control", modal_hdr->lna_ctl);
  600. - PR_EEP("XPA Bias Freq0", modal_hdr->xpaBiasLvlFreq[0]);
  601. - PR_EEP("XPA Bias Freq1", modal_hdr->xpaBiasLvlFreq[1]);
  602. - PR_EEP("XPA Bias Freq2", modal_hdr->xpaBiasLvlFreq[2]);
  603. + PR_EEP("XPA Bias Freq0", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[0]));
  604. + PR_EEP("XPA Bias Freq1", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[1]));
  605. + PR_EEP("XPA Bias Freq2", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[2]));
  606. return len;
  607. }
  608. @@ -206,6 +206,7 @@ static u32 ath9k_hw_def_dump_eeprom(stru
  609. {
  610. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  611. struct base_eep_header *pBase = &eep->baseEepHeader;
  612. + u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
  613. if (!dump_base_hdr) {
  614. len += scnprintf(buf + len, size - len,
  615. @@ -221,10 +222,10 @@ static u32 ath9k_hw_def_dump_eeprom(stru
  616. PR_EEP("Major Version", ath9k_hw_def_get_eeprom_ver(ah));
  617. PR_EEP("Minor Version", ath9k_hw_def_get_eeprom_rev(ah));
  618. - PR_EEP("Checksum", pBase->checksum);
  619. - PR_EEP("Length", pBase->length);
  620. - PR_EEP("RegDomain1", pBase->regDmn[0]);
  621. - PR_EEP("RegDomain2", pBase->regDmn[1]);
  622. + PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
  623. + PR_EEP("Length", le16_to_cpu(pBase->length));
  624. + PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  625. + PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  626. PR_EEP("TX Mask", pBase->txMask);
  627. PR_EEP("RX Mask", pBase->rxMask);
  628. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
  629. @@ -238,9 +239,9 @@ static u32 ath9k_hw_def_dump_eeprom(stru
  630. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
  631. AR5416_OPFLAGS_N_5G_HT40));
  632. PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
  633. - PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
  634. - PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
  635. - PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
  636. + PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
  637. + PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
  638. + PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
  639. PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
  640. len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
  641. @@ -273,61 +274,40 @@ static int ath9k_hw_def_check_eeprom(str
  642. return err;
  643. if (need_swap)
  644. - el = swab16(eep->baseEepHeader.length);
  645. + el = swab16((__force u16)eep->baseEepHeader.length);
  646. else
  647. - el = eep->baseEepHeader.length;
  648. + el = le16_to_cpu(eep->baseEepHeader.length);
  649. el = min(el / sizeof(u16), SIZE_EEPROM_DEF);
  650. if (!ath9k_hw_nvram_validate_checksum(ah, el))
  651. return -EINVAL;
  652. if (need_swap) {
  653. - u32 integer, j;
  654. - u16 word;
  655. + u32 j;
  656. - word = swab16(eep->baseEepHeader.length);
  657. - eep->baseEepHeader.length = word;
  658. -
  659. - word = swab16(eep->baseEepHeader.checksum);
  660. - eep->baseEepHeader.checksum = word;
  661. -
  662. - word = swab16(eep->baseEepHeader.version);
  663. - eep->baseEepHeader.version = word;
  664. -
  665. - word = swab16(eep->baseEepHeader.regDmn[0]);
  666. - eep->baseEepHeader.regDmn[0] = word;
  667. -
  668. - word = swab16(eep->baseEepHeader.regDmn[1]);
  669. - eep->baseEepHeader.regDmn[1] = word;
  670. -
  671. - word = swab16(eep->baseEepHeader.rfSilent);
  672. - eep->baseEepHeader.rfSilent = word;
  673. -
  674. - word = swab16(eep->baseEepHeader.blueToothOptions);
  675. - eep->baseEepHeader.blueToothOptions = word;
  676. -
  677. - word = swab16(eep->baseEepHeader.deviceCap);
  678. - eep->baseEepHeader.deviceCap = word;
  679. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
  680. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
  681. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
  682. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
  683. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
  684. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
  685. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
  686. + EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
  687. for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) {
  688. struct modal_eep_header *pModal =
  689. &eep->modalHeader[j];
  690. - integer = swab32(pModal->antCtrlCommon);
  691. - pModal->antCtrlCommon = integer;
  692. + EEPROM_FIELD_SWAB32(pModal->antCtrlCommon);
  693. - for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  694. - integer = swab32(pModal->antCtrlChain[i]);
  695. - pModal->antCtrlChain[i] = integer;
  696. - }
  697. - for (i = 0; i < 3; i++) {
  698. - word = swab16(pModal->xpaBiasLvlFreq[i]);
  699. - pModal->xpaBiasLvlFreq[i] = word;
  700. - }
  701. + for (i = 0; i < AR5416_MAX_CHAINS; i++)
  702. + EEPROM_FIELD_SWAB32(pModal->antCtrlChain[i]);
  703. - for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  704. - word = swab16(pModal->spurChans[i].spurChan);
  705. - pModal->spurChans[i].spurChan = word;
  706. - }
  707. + for (i = 0; i < 3; i++)
  708. + EEPROM_FIELD_SWAB16(pModal->xpaBiasLvlFreq[i]);
  709. +
  710. + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
  711. + EEPROM_FIELD_SWAB16(
  712. + pModal->spurChans[i].spurChan);
  713. }
  714. }
  715. @@ -337,7 +317,7 @@ static int ath9k_hw_def_check_eeprom(str
  716. /* Enable fixup for AR_AN_TOP2 if necessary */
  717. if ((ah->hw_version.devid == AR9280_DEVID_PCI) &&
  718. - ((eep->baseEepHeader.version & 0xff) > 0x0a) &&
  719. + ((le16_to_cpu(eep->baseEepHeader.version) & 0xff) > 0x0a) &&
  720. (eep->baseEepHeader.pwdclkind == 0))
  721. ah->need_an_top2_fixup = true;
  722. @@ -370,13 +350,13 @@ static u32 ath9k_hw_def_get_eeprom(struc
  723. case EEP_MAC_MSW:
  724. return get_unaligned_be16(pBase->macAddr + 4);
  725. case EEP_REG_0:
  726. - return pBase->regDmn[0];
  727. + return le16_to_cpu(pBase->regDmn[0]);
  728. case EEP_OP_CAP:
  729. - return pBase->deviceCap;
  730. + return le16_to_cpu(pBase->deviceCap);
  731. case EEP_OP_MODE:
  732. return pBase->opCapFlags;
  733. case EEP_RF_SILENT:
  734. - return pBase->rfSilent;
  735. + return le16_to_cpu(pBase->rfSilent);
  736. case EEP_OB_5:
  737. return pModal[0].ob;
  738. case EEP_DB_5:
  739. @@ -490,11 +470,13 @@ static void ath9k_hw_def_set_board_value
  740. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  741. int i, regChainOffset;
  742. u8 txRxAttenLocal;
  743. + u32 antCtrlCommon;
  744. pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
  745. txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44;
  746. + antCtrlCommon = le32_to_cpu(pModal->antCtrlCommon);
  747. - REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon & 0xffff);
  748. + REG_WRITE(ah, AR_PHY_SWITCH_COM, antCtrlCommon & 0xffff);
  749. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  750. if (AR_SREV_9280(ah)) {
  751. @@ -508,7 +490,7 @@ static void ath9k_hw_def_set_board_value
  752. regChainOffset = i * 0x1000;
  753. REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
  754. - pModal->antCtrlChain[i]);
  755. + le32_to_cpu(pModal->antCtrlChain[i]));
  756. REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
  757. (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset) &
  758. @@ -655,7 +637,7 @@ static void ath9k_hw_def_set_board_value
  759. static void ath9k_hw_def_set_addac(struct ath_hw *ah,
  760. struct ath9k_channel *chan)
  761. {
  762. -#define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt])
  763. +#define XPA_LVL_FREQ(cnt) (le16_to_cpu(pModal->xpaBiasLvlFreq[cnt]))
  764. struct modal_eep_header *pModal;
  765. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  766. u8 biaslevel;
  767. @@ -1315,7 +1297,9 @@ static void ath9k_hw_def_set_txpower(str
  768. static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
  769. {
  770. - return ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan;
  771. + __le16 spch = ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan;
  772. +
  773. + return le16_to_cpu(spch);
  774. }
  775. static u8 ath9k_hw_def_get_eepmisc(struct ath_hw *ah)