提交 1409a932 编写于 作者: J Joe Perches 提交者: David S. Miller

ethernet: Convert mac address uses of 6 to ETH_ALEN

Use the normal #define to help grep find mac addresses
and ensure that addresses are aligned.

pasemi.h has an unaligned access to mac_addr, unchanged
for now.
Signed-off-by: NJoe Perches <joe@perches.com>
Acked-by: Olof Johansson <olof@lixom.net> # pasemi_mac pieces
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 574e2af7
...@@ -707,7 +707,7 @@ static int ax_init_dev(struct net_device *dev) ...@@ -707,7 +707,7 @@ static int ax_init_dev(struct net_device *dev)
#ifdef CONFIG_AX88796_93CX6 #ifdef CONFIG_AX88796_93CX6
if (ax->plat->flags & AXFLG_HAS_93CX6) { if (ax->plat->flags & AXFLG_HAS_93CX6) {
unsigned char mac_addr[6]; unsigned char mac_addr[ETH_ALEN];
struct eeprom_93cx6 eeprom; struct eeprom_93cx6 eeprom;
eeprom.data = ei_local; eeprom.data = ei_local;
...@@ -719,7 +719,7 @@ static int ax_init_dev(struct net_device *dev) ...@@ -719,7 +719,7 @@ static int ax_init_dev(struct net_device *dev)
(__le16 __force *)mac_addr, (__le16 __force *)mac_addr,
sizeof(mac_addr) >> 1); sizeof(mac_addr) >> 1);
memcpy(dev->dev_addr, mac_addr, 6); memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
} }
#endif #endif
if (ax->plat->wordlength == 2) { if (ax->plat->wordlength == 2) {
......
...@@ -1521,7 +1521,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) ...@@ -1521,7 +1521,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
char *chipname; char *chipname;
struct net_device *dev; struct net_device *dev;
const struct pcnet32_access *a = NULL; const struct pcnet32_access *a = NULL;
u8 promaddr[6]; u8 promaddr[ETH_ALEN];
int ret = -ENODEV; int ret = -ENODEV;
/* reset the chip */ /* reset the chip */
...@@ -1665,10 +1665,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) ...@@ -1665,10 +1665,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
} }
/* read PROM address and compare with CSR address */ /* read PROM address and compare with CSR address */
for (i = 0; i < 6; i++) for (i = 0; i < ETH_ALEN; i++)
promaddr[i] = inb(ioaddr + i); promaddr[i] = inb(ioaddr + i);
if (memcmp(promaddr, dev->dev_addr, 6) || if (memcmp(promaddr, dev->dev_addr, ETH_ALEN) ||
!is_valid_ether_addr(dev->dev_addr)) { !is_valid_ether_addr(dev->dev_addr)) {
if (is_valid_ether_addr(promaddr)) { if (is_valid_ether_addr(promaddr)) {
if (pcnet32_debug & NETIF_MSG_PROBE) { if (pcnet32_debug & NETIF_MSG_PROBE) {
......
...@@ -238,8 +238,8 @@ struct cnic_sock { ...@@ -238,8 +238,8 @@ struct cnic_sock {
u16 src_port; u16 src_port;
u16 dst_port; u16 dst_port;
u16 vlan_id; u16 vlan_id;
unsigned char old_ha[6]; unsigned char old_ha[ETH_ALEN];
unsigned char ha[6]; unsigned char ha[ETH_ALEN];
u32 mtu; u32 mtu;
u32 cid; u32 cid;
u32 l5_cid; u32 l5_cid;
...@@ -308,7 +308,7 @@ struct cnic_dev { ...@@ -308,7 +308,7 @@ struct cnic_dev {
#define CNIC_F_BNX2_CLASS 3 #define CNIC_F_BNX2_CLASS 3
#define CNIC_F_BNX2X_CLASS 4 #define CNIC_F_BNX2X_CLASS 4
atomic_t ref_count; atomic_t ref_count;
u8 mac_addr[6]; u8 mac_addr[ETH_ALEN];
int max_iscsi_conn; int max_iscsi_conn;
int max_fcoe_conn; int max_fcoe_conn;
......
...@@ -1304,7 +1304,9 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1304,7 +1304,9 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
struct tulip_private *tp; struct tulip_private *tp;
/* See note below on the multiport cards. */ /* See note below on the multiport cards. */
static unsigned char last_phys_addr[6] = {0x00, 'L', 'i', 'n', 'u', 'x'}; static unsigned char last_phys_addr[ETH_ALEN] = {
0x00, 'L', 'i', 'n', 'u', 'x'
};
static int last_irq; static int last_irq;
static int multiport_cnt; /* For four-port boards w/one EEPROM */ static int multiport_cnt; /* For four-port boards w/one EEPROM */
int i, irq; int i, irq;
...@@ -1627,8 +1629,8 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1627,8 +1629,8 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->dev_addr[i] = last_phys_addr[i] + 1; dev->dev_addr[i] = last_phys_addr[i] + 1;
#if defined(CONFIG_SPARC) #if defined(CONFIG_SPARC)
addr = of_get_property(dp, "local-mac-address", &len); addr = of_get_property(dp, "local-mac-address", &len);
if (addr && len == 6) if (addr && len == ETH_ALEN)
memcpy(dev->dev_addr, addr, 6); memcpy(dev->dev_addr, addr, ETH_ALEN);
#endif #endif
#if defined(__i386__) || defined(__x86_64__) /* Patch up x86 BIOS bug. */ #if defined(__i386__) || defined(__x86_64__) /* Patch up x86 BIOS bug. */
if (last_irq) if (last_irq)
......
...@@ -133,8 +133,8 @@ struct rfd_struct ...@@ -133,8 +133,8 @@ struct rfd_struct
unsigned char last; /* Bit15,Last Frame on List / Bit14,suspend */ unsigned char last; /* Bit15,Last Frame on List / Bit14,suspend */
unsigned short next; /* linkoffset to next RFD */ unsigned short next; /* linkoffset to next RFD */
unsigned short rbd_offset; /* pointeroffset to RBD-buffer */ unsigned short rbd_offset; /* pointeroffset to RBD-buffer */
unsigned char dest[6]; /* ethernet-address, destination */ unsigned char dest[ETH_ALEN]; /* ethernet-address, destination */
unsigned char source[6]; /* ethernet-address, source */ unsigned char source[ETH_ALEN]; /* ethernet-address, source */
unsigned short length; /* 802.3 frame-length */ unsigned short length; /* 802.3 frame-length */
unsigned short zero_dummy; /* dummy */ unsigned short zero_dummy; /* dummy */
}; };
......
...@@ -244,7 +244,7 @@ struct myri10ge_priv { ...@@ -244,7 +244,7 @@ struct myri10ge_priv {
int fw_ver_minor; int fw_ver_minor;
int fw_ver_tiny; int fw_ver_tiny;
int adopted_rx_filter_bug; int adopted_rx_filter_bug;
u8 mac_addr[6]; /* eeprom mac address */ u8 mac_addr[ETH_ALEN]; /* eeprom mac address */
unsigned long serial_number; unsigned long serial_number;
int vendor_specific_offset; int vendor_specific_offset;
int fw_multicast_support; int fw_multicast_support;
......
...@@ -922,7 +922,7 @@ static void __init get_mac_address(struct net_device *dev) ...@@ -922,7 +922,7 @@ static void __init get_mac_address(struct net_device *dev)
{ {
struct w90p910_ether *ether = netdev_priv(dev); struct w90p910_ether *ether = netdev_priv(dev);
struct platform_device *pdev; struct platform_device *pdev;
char addr[6]; char addr[ETH_ALEN];
pdev = ether->pdev; pdev = ether->pdev;
...@@ -934,7 +934,7 @@ static void __init get_mac_address(struct net_device *dev) ...@@ -934,7 +934,7 @@ static void __init get_mac_address(struct net_device *dev)
addr[5] = 0xa8; addr[5] = 0xa8;
if (is_valid_ether_addr(addr)) if (is_valid_ether_addr(addr))
memcpy(dev->dev_addr, &addr, 0x06); memcpy(dev->dev_addr, &addr, ETH_ALEN);
else else
dev_err(&pdev->dev, "invalid mac address\n"); dev_err(&pdev->dev, "invalid mac address\n");
} }
......
...@@ -191,7 +191,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) ...@@ -191,7 +191,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
struct device_node *dn = pci_device_to_OF_node(pdev); struct device_node *dn = pci_device_to_OF_node(pdev);
int len; int len;
const u8 *maddr; const u8 *maddr;
u8 addr[6]; u8 addr[ETH_ALEN];
if (!dn) { if (!dn) {
dev_dbg(&pdev->dev, dev_dbg(&pdev->dev,
...@@ -201,8 +201,8 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) ...@@ -201,8 +201,8 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
maddr = of_get_property(dn, "local-mac-address", &len); maddr = of_get_property(dn, "local-mac-address", &len);
if (maddr && len == 6) { if (maddr && len == ETH_ALEN) {
memcpy(mac->mac_addr, maddr, 6); memcpy(mac->mac_addr, maddr, ETH_ALEN);
return 0; return 0;
} }
...@@ -219,14 +219,15 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) ...@@ -219,14 +219,15 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
return -ENOENT; return -ENOENT;
} }
if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[0], if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6) { &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
!= ETH_ALEN) {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
"can't parse mac address, not configuring\n"); "can't parse mac address, not configuring\n");
return -EINVAL; return -EINVAL;
} }
memcpy(mac->mac_addr, addr, 6); memcpy(mac->mac_addr, addr, ETH_ALEN);
return 0; return 0;
} }
......
...@@ -83,7 +83,7 @@ struct pasemi_mac { ...@@ -83,7 +83,7 @@ struct pasemi_mac {
#define MAC_TYPE_GMAC 1 #define MAC_TYPE_GMAC 1
#define MAC_TYPE_XAUI 2 #define MAC_TYPE_XAUI 2
u8 mac_addr[6]; u8 mac_addr[ETH_ALEN];
struct net_lro_mgr lro_mgr; struct net_lro_mgr lro_mgr;
struct net_lro_desc lro_desc[MAX_LRO_DESCRIPTORS]; struct net_lro_desc lro_desc[MAX_LRO_DESCRIPTORS];
......
...@@ -536,10 +536,10 @@ static void netxen_p2_nic_set_multi(struct net_device *netdev) ...@@ -536,10 +536,10 @@ static void netxen_p2_nic_set_multi(struct net_device *netdev)
{ {
struct netxen_adapter *adapter = netdev_priv(netdev); struct netxen_adapter *adapter = netdev_priv(netdev);
struct netdev_hw_addr *ha; struct netdev_hw_addr *ha;
u8 null_addr[6]; u8 null_addr[ETH_ALEN];
int i; int i;
memset(null_addr, 0, 6); memset(null_addr, 0, ETH_ALEN);
if (netdev->flags & IFF_PROMISC) { if (netdev->flags & IFF_PROMISC) {
......
...@@ -2149,7 +2149,7 @@ struct ql_adapter { ...@@ -2149,7 +2149,7 @@ struct ql_adapter {
struct timer_list timer; struct timer_list timer;
atomic_t lb_count; atomic_t lb_count;
/* Keep local copy of current mac address. */ /* Keep local copy of current mac address. */
char current_mac_addr[6]; char current_mac_addr[ETH_ALEN];
}; };
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册