igb: clean up code for setting MAC address
authorAlexander Duyck <aduyck@mirantis.com>
Thu, 7 Jan 2016 07:10:23 +0000 (23:10 -0800)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tue, 16 Feb 2016 00:21:05 +0000 (16:21 -0800)
Drop a bunch of hand written byte swapping code in favor of just doing the
byte swapping ourselves.  The registers are little endian registers storing
a big endian value so if we read the MAC address array as little endian
then we will get the CPU registers into the proper layout.

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/igb/igb_main.c

index 85c47aa16a31f4c82b56200ac603c5df75e42ec1..02f19e45d6fdef045ae13644d5d29e0811ef2fd8 100644 (file)
@@ -7698,15 +7698,14 @@ static void igb_io_resume(struct pci_dev *pdev)
 static void igb_rar_set_qsel(struct igb_adapter *adapter, u8 *addr, u32 index,
                             u8 qsel)
 {
-       u32 rar_low, rar_high;
        struct e1000_hw *hw = &adapter->hw;
+       u32 rar_low, rar_high;
 
        /* HW expects these in little endian so we reverse the byte order
-        * from network order (big endian) to little endian
+        * from network order (big endian) to CPU endian
         */
-       rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
-                  ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
-       rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
+       rar_low = le32_to_cpup((__be32 *)(addr));
+       rar_high = le16_to_cpup((__be16 *)(addr + 4));
 
        /* Indicate to hardware the Address is Valid. */
        rar_high |= E1000_RAH_AV;
This page took 0.028515 seconds and 5 git commands to generate.