Skip to content

Commit

Permalink
iwlwifi: use big-endian for the hw section of the nvm
Browse files Browse the repository at this point in the history
Unlike the other sections of the NVM, the hw section is in big-endian.
To read a value from it, we had to cast it to __be16.  Fix that by
using __be16 * for the entire section.

Signed-off-by: Luca Coelho <[email protected]>
  • Loading branch information
lucacoelho committed Aug 18, 2017
1 parent ee4fe54 commit 8fe34b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
11 changes: 5 additions & 6 deletions drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ static void iwl_set_hw_address_family_8000(struct iwl_trans *trans,
const struct iwl_cfg *cfg,
struct iwl_nvm_data *data,
const __le16 *mac_override,
const __le16 *nvm_hw)
const __be16 *nvm_hw)
{
const u8 *hw_addr;

Expand Down Expand Up @@ -629,7 +629,7 @@ static void iwl_set_hw_address_family_8000(struct iwl_trans *trans,

static int iwl_set_hw_address(struct iwl_trans *trans,
const struct iwl_cfg *cfg,
struct iwl_nvm_data *data, const __le16 *nvm_hw,
struct iwl_nvm_data *data, const __be16 *nvm_hw,
const __le16 *mac_override)
{
if (cfg->mac_addr_from_csr) {
Expand Down Expand Up @@ -661,7 +661,7 @@ static int iwl_set_hw_address(struct iwl_trans *trans,

static bool
iwl_nvm_no_wide_in_5ghz(struct device *dev, const struct iwl_cfg *cfg,
const __le16 *nvm_hw)
const __be16 *nvm_hw)
{
/*
* Workaround a bug in Indonesia SKUs where the regulatory in
Expand All @@ -677,8 +677,7 @@ iwl_nvm_no_wide_in_5ghz(struct device *dev, const struct iwl_cfg *cfg,
* Unlike the other sections in the NVM, the hw
* section uses big-endian.
*/
u16 subsystem_id = be16_to_cpup((const __be16 *)nvm_hw
+ SUBSYSTEM_ID);
u16 subsystem_id = be16_to_cpup(nvm_hw + SUBSYSTEM_ID);
u8 sku = (subsystem_id & 0x1e) >> 1;

if (sku == 5 || sku == 9) {
Expand All @@ -694,7 +693,7 @@ iwl_nvm_no_wide_in_5ghz(struct device *dev, const struct iwl_cfg *cfg,

struct iwl_nvm_data *
iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
const __le16 *nvm_hw, const __le16 *nvm_sw,
const __be16 *nvm_hw, const __le16 *nvm_sw,
const __le16 *nvm_calib, const __le16 *regulatory,
const __le16 *mac_override, const __le16 *phy_sku,
u8 tx_chains, u8 rx_chains, bool lar_fw_supported)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
*/
struct iwl_nvm_data *
iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
const __le16 *nvm_hw, const __le16 *nvm_sw,
const __be16 *nvm_hw, const __le16 *nvm_sw,
const __le16 *nvm_calib, const __le16 *regulatory,
const __le16 *mac_override, const __le16 *phy_sku,
u8 tx_chains, u8 rx_chains, bool lar_fw_supported);
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ static struct iwl_nvm_data *
iwl_parse_nvm_sections(struct iwl_mvm *mvm)
{
struct iwl_nvm_section *sections = mvm->nvm_sections;
const __le16 *hw, *sw, *calib, *regulatory, *mac_override, *phy_sku;
const __be16 *hw;
const __le16 *sw, *calib, *regulatory, *mac_override, *phy_sku;
bool lar_enabled;

/* Checking for required sections */
Expand Down Expand Up @@ -326,7 +327,7 @@ iwl_parse_nvm_sections(struct iwl_mvm *mvm)
}
}

hw = (const __le16 *)sections[mvm->cfg->nvm_hw_section_num].data;
hw = (const __be16 *)sections[mvm->cfg->nvm_hw_section_num].data;
sw = (const __le16 *)sections[NVM_SECTION_TYPE_SW].data;
calib = (const __le16 *)sections[NVM_SECTION_TYPE_CALIBRATION].data;
regulatory = (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY].data;
Expand Down

0 comments on commit 8fe34b0

Please sign in to comment.