Skip to content

Commit

Permalink
atlx: Use ETH_ALEN
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joe Perches authored and David S. Miller committed Mar 19, 2012
1 parent a3f671b commit c81f212
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
13 changes: 5 additions & 8 deletions drivers/net/ethernet/atheros/atlx/atl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
}

Expand All @@ -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? */
Expand All @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/atheros/atlx/atl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down Expand Up @@ -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; */
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/atheros/atlx/atlx.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@

/* 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 */
Expand Down

0 comments on commit c81f212

Please sign in to comment.