iwlwifi: check for valid ethernet address provided by OEM
authorHaim Dreyfuss <haim.dreyfuss@intel.com>
Tue, 2 Aug 2016 12:28:23 +0000 (15:28 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Mon, 19 Sep 2016 07:09:27 +0000 (10:09 +0300)
In 9000 family products we added an option to let the OEM fuse the
mac address via registers. If these registers are zeroed we use the OTP
address instead. Make sure that the address provided by the OEM is valid
and, if not, fall back to the OTP address as well.

Fixes: commit 17c867bfe89b ("iwlwifi: add support for getting HW address from CSR")
Signed-off-by: Haim Dreyfuss <haim.dreyfuss@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c

index 43f8f7d45ddb10e8753bde3252e7c63c9450d505..adba3b003f55e7c9338f35db919fc2f4bc34c4a6 100644 (file)
@@ -564,11 +564,16 @@ static void iwl_set_hw_address_from_csr(struct iwl_trans *trans,
        __le32 mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_STRAP));
        __le32 mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_STRAP));
 
-       /* If OEM did not fuse address - get it from OTP */
-       if (!mac_addr0 && !mac_addr1) {
-               mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_OTP));
-               mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_OTP));
-       }
+       iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr);
+       /*
+        * If the OEM fused a valid address, use it instead of the one in the
+        * OTP
+        */
+       if (is_valid_ether_addr(data->hw_addr))
+               return;
+
+       mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_OTP));
+       mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_OTP));
 
        iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr);
 }