Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c81f2124 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller
Browse files

atlx: Use ETH_ALEN



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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a3f671b3
Loading
Loading
Loading
Loading
+5 −8
Original line number Original line Diff line number Diff line
@@ -2258,7 +2258,7 @@ static int get_permanent_address(struct atl2_hw *hw)
	u32 Addr[2];
	u32 Addr[2];
	u32 i, Control;
	u32 i, Control;
	u16 Register;
	u16 Register;
	u8  EthAddr[NODE_ADDRESS_SIZE];
	u8  EthAddr[ETH_ALEN];
	bool KeyValid;
	bool KeyValid;


	if (is_valid_ether_addr(hw->perm_mac_addr))
	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]);
		*(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *) &Addr[1]);


		if (is_valid_ether_addr(EthAddr)) {
		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 0;
		}
		}
		return 1;
		return 1;
@@ -2334,7 +2334,7 @@ static int get_permanent_address(struct atl2_hw *hw)
	*(u32 *) &EthAddr[2] = LONGSWAP(Addr[0]);
	*(u32 *) &EthAddr[2] = LONGSWAP(Addr[0]);
	*(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *)&Addr[1]);
	*(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *)&Addr[1]);
	if (is_valid_ether_addr(EthAddr)) {
	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 0;
	}
	}
	/* maybe MAC-address is from BIOS */
	/* 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]);
	*(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *) &Addr[1]);


	if (is_valid_ether_addr(EthAddr)) {
	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 0;
	}
	}


@@ -2358,8 +2358,6 @@ static int get_permanent_address(struct atl2_hw *hw)
 */
 */
static s32 atl2_read_mac_addr(struct atl2_hw *hw)
static s32 atl2_read_mac_addr(struct atl2_hw *hw)
{
{
	u16 i;

	if (get_permanent_address(hw)) {
	if (get_permanent_address(hw)) {
		/* for test */
		/* for test */
		/* FIXME: shouldn't we use random_ether_addr() here? */
		/* 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;
		hw->perm_mac_addr[5] = 0x38;
	}
	}


	for (i = 0; i < NODE_ADDRESS_SIZE; i++)
	memcpy(hw->mac_addr, hw->perm_mac_addr, ETH_ALEN);
		hw->mac_addr[i] = hw->perm_mac_addr[i];


	return 0;
	return 0;
}
}
+2 −3
Original line number Original line Diff line number Diff line
@@ -47,7 +47,6 @@ extern int ethtool_ioctl(struct ifreq *ifr);


#define PCI_COMMAND_REGISTER	PCI_COMMAND
#define PCI_COMMAND_REGISTER	PCI_COMMAND
#define CMD_MEM_WRT_INVALIDATE	PCI_COMMAND_INVALIDATE
#define CMD_MEM_WRT_INVALIDATE	PCI_COMMAND_INVALIDATE
#define ETH_ADDR_LEN		ETH_ALEN


#define ATL2_WRITE_REG(a, reg, value) (iowrite32((value), \
#define ATL2_WRITE_REG(a, reg, value) (iowrite32((value), \
	((a)->hw_addr + (reg))))
	((a)->hw_addr + (reg))))
@@ -429,8 +428,8 @@ struct atl2_hw {
	u8 flash_vendor;
	u8 flash_vendor;


	u8 dma_fairness;
	u8 dma_fairness;
	u8 mac_addr[NODE_ADDRESS_SIZE];
	u8 mac_addr[ETH_ALEN];
	u8 perm_mac_addr[NODE_ADDRESS_SIZE];
	u8 perm_mac_addr[ETH_ALEN];


	/* FIXME */
	/* FIXME */
	/* bool phy_preamble_sup; */
	/* bool phy_preamble_sup; */
+0 −1
Original line number Original line Diff line number Diff line
@@ -484,7 +484,6 @@


/* For checksumming, the sum of all words in the EEPROM should equal 0xBABA */
/* For checksumming, the sum of all words in the EEPROM should equal 0xBABA */
#define EEPROM_SUM			0xBABA
#define EEPROM_SUM			0xBABA
#define NODE_ADDRESS_SIZE		6


struct atlx_spi_flash_dev {
struct atlx_spi_flash_dev {
	const char *manu_name;	/* manufacturer id */
	const char *manu_name;	/* manufacturer id */