iwlwifi: use big-endian for the hw section of the nvm
authorLuca Coelho <luciano.coelho@intel.com>
Thu, 17 Aug 2017 15:51:56 +0000 (18:51 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 18 Aug 2017 14:36:42 +0000 (17:36 +0300)
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 <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
drivers/net/wireless/intel/iwlwifi/mvm/nvm.c

index ea165b3e6dd3ec461fbad12af4633315b5454365..aa382f7199882c6a3a292dd83e22f05e967bfa8e 100644 (file)
@@ -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;
 
@@ -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) {
@@ -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
@@ -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) {
@@ -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)
index 50d9b3eaa4f88825f56731267814446fffedbcef..2d1a24dd8410947c0095458b3e2925a7cee6c62d 100644 (file)
@@ -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);
index b05673e4a19349b7023b0072dda12eda2ee267f5..422aa6be99328b2f7dfe66db69c724bbe3824291 100644 (file)
@@ -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 */
@@ -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;