atlx: Use ETH_ALEN
authorJoe Perches <joe@perches.com>
Sun, 18 Mar 2012 17:37:57 +0000 (17:37 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 Mar 2012 20:53:08 +0000 (16:53 -0400)
No need for yet another #define for this.

Convert NODE_ADDRESS_SIZE use to ETH_ALEN and remove #define.
Use memcpy instead of a loop to copy an address.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/atheros/atlx/atl2.c
drivers/net/ethernet/atheros/atlx/atl2.h
drivers/net/ethernet/atheros/atlx/atlx.h

index 071f4c858969dad5ff166d69f62073f4c0518b09..6762dc406b25ab10c1424e899f8d16913088c35e 100644 (file)
@@ -2258,7 +2258,7 @@ static int get_permanent_address(struct atl2_hw *hw)
        u32 Addr[2];
        u32 i, Control;
        u16 Register;
-       u8  EthAddr[NODE_ADDRESS_SIZE];
+       u8  EthAddr[ETH_ALEN];
        bool KeyValid;
 
        if (is_valid_ether_addr(hw->perm_mac_addr))
@@ -2299,7 +2299,7 @@ static int get_permanent_address(struct atl2_hw *hw)
                *(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *) &Addr[1]);
 
                if (is_valid_ether_addr(EthAddr)) {
-                       memcpy(hw->perm_mac_addr, EthAddr, NODE_ADDRESS_SIZE);
+                       memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN);
                        return 0;
                }
                return 1;
@@ -2334,7 +2334,7 @@ static int get_permanent_address(struct atl2_hw *hw)
        *(u32 *) &EthAddr[2] = LONGSWAP(Addr[0]);
        *(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *)&Addr[1]);
        if (is_valid_ether_addr(EthAddr)) {
-               memcpy(hw->perm_mac_addr, EthAddr, NODE_ADDRESS_SIZE);
+               memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN);
                return 0;
        }
        /* maybe MAC-address is from BIOS */
@@ -2344,7 +2344,7 @@ static int get_permanent_address(struct atl2_hw *hw)
        *(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *) &Addr[1]);
 
        if (is_valid_ether_addr(EthAddr)) {
-               memcpy(hw->perm_mac_addr, EthAddr, NODE_ADDRESS_SIZE);
+               memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN);
                return 0;
        }
 
@@ -2358,8 +2358,6 @@ static int get_permanent_address(struct atl2_hw *hw)
  */
 static s32 atl2_read_mac_addr(struct atl2_hw *hw)
 {
-       u16 i;
-
        if (get_permanent_address(hw)) {
                /* for test */
                /* FIXME: shouldn't we use random_ether_addr() here? */
@@ -2371,8 +2369,7 @@ static s32 atl2_read_mac_addr(struct atl2_hw *hw)
                hw->perm_mac_addr[5] = 0x38;
        }
 
-       for (i = 0; i < NODE_ADDRESS_SIZE; i++)
-               hw->mac_addr[i] = hw->perm_mac_addr[i];
+       memcpy(hw->mac_addr, hw->perm_mac_addr, ETH_ALEN);
 
        return 0;
 }
index bf9016ebdd9bd637884bb598e9af61e2829cd205..3ebe19f7242b6da9cd5d3290674f85cb9e164013 100644 (file)
@@ -47,7 +47,6 @@ extern int ethtool_ioctl(struct ifreq *ifr);
 
 #define PCI_COMMAND_REGISTER   PCI_COMMAND
 #define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
-#define ETH_ADDR_LEN           ETH_ALEN
 
 #define ATL2_WRITE_REG(a, reg, value) (iowrite32((value), \
        ((a)->hw_addr + (reg))))
@@ -429,8 +428,8 @@ struct atl2_hw {
        u8 flash_vendor;
 
        u8 dma_fairness;
-       u8 mac_addr[NODE_ADDRESS_SIZE];
-       u8 perm_mac_addr[NODE_ADDRESS_SIZE];
+       u8 mac_addr[ETH_ALEN];
+       u8 perm_mac_addr[ETH_ALEN];
 
        /* FIXME */
        /* bool phy_preamble_sup; */
index 14054b75aa62684424fedaff97147cbfde1db46e..448f5dcc02e662eb1441745b5705e46952274a29 100644 (file)
 
 /* For checksumming, the sum of all words in the EEPROM should equal 0xBABA */
 #define EEPROM_SUM                     0xBABA
-#define NODE_ADDRESS_SIZE              6
 
 struct atlx_spi_flash_dev {
        const char *manu_name;  /* manufacturer id */