Commit 562ef98a authored by Jakub Kicinski's avatar Jakub Kicinski

ethernet: replace netdev->dev_addr assignment loops

A handful of drivers contains loops assigning the mac
addr byte by byte. Convert those to eth_hw_addr_set().
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 68a06402
...@@ -305,7 +305,6 @@ static int __init lance_probe( struct net_device *dev) ...@@ -305,7 +305,6 @@ static int __init lance_probe( struct net_device *dev)
unsigned long ioaddr; unsigned long ioaddr;
struct lance_private *lp; struct lance_private *lp;
int i;
static int did_version; static int did_version;
volatile unsigned short *ioaddr_probe; volatile unsigned short *ioaddr_probe;
unsigned short tmp1, tmp2; unsigned short tmp1, tmp2;
...@@ -373,8 +372,7 @@ static int __init lance_probe( struct net_device *dev) ...@@ -373,8 +372,7 @@ static int __init lance_probe( struct net_device *dev)
dev->irq); dev->irq);
/* copy in the ethernet address from the prom */ /* copy in the ethernet address from the prom */
for(i = 0; i < 6 ; i++) eth_hw_addr_set(dev, idprom->id_ethaddr);
dev->dev_addr[i] = idprom->id_ethaddr[i];
/* tell the card it's ether address, bytes swapped */ /* tell the card it's ether address, bytes swapped */
MEM->init.hwaddr[0] = dev->dev_addr[1]; MEM->init.hwaddr[0] = dev->dev_addr[1];
......
...@@ -1301,7 +1301,6 @@ static int sparc_lance_probe_one(struct platform_device *op, ...@@ -1301,7 +1301,6 @@ static int sparc_lance_probe_one(struct platform_device *op,
struct device_node *dp = op->dev.of_node; struct device_node *dp = op->dev.of_node;
struct lance_private *lp; struct lance_private *lp;
struct net_device *dev; struct net_device *dev;
int i;
dev = alloc_etherdev(sizeof(struct lance_private) + 8); dev = alloc_etherdev(sizeof(struct lance_private) + 8);
if (!dev) if (!dev)
...@@ -1315,8 +1314,7 @@ static int sparc_lance_probe_one(struct platform_device *op, ...@@ -1315,8 +1314,7 @@ static int sparc_lance_probe_one(struct platform_device *op,
* will copy the address in the device structure to the lance * will copy the address in the device structure to the lance
* initialization block. * initialization block.
*/ */
for (i = 0; i < 6; i++) eth_hw_addr_set(dev, idprom->id_ethaddr);
dev->dev_addr[i] = idprom->id_ethaddr[i];
/* Get the IO region */ /* Get the IO region */
lp->lregs = of_ioremap(&op->resource[0], 0, lp->lregs = of_ioremap(&op->resource[0], 0,
......
...@@ -521,17 +521,14 @@ static int bmac_resume(struct macio_dev *mdev) ...@@ -521,17 +521,14 @@ static int bmac_resume(struct macio_dev *mdev)
static int bmac_set_address(struct net_device *dev, void *addr) static int bmac_set_address(struct net_device *dev, void *addr)
{ {
struct bmac_data *bp = netdev_priv(dev); struct bmac_data *bp = netdev_priv(dev);
unsigned char *p = addr;
const unsigned short *pWord16; const unsigned short *pWord16;
unsigned long flags; unsigned long flags;
int i;
XXDEBUG(("bmac: enter set_address\n")); XXDEBUG(("bmac: enter set_address\n"));
spin_lock_irqsave(&bp->lock, flags); spin_lock_irqsave(&bp->lock, flags);
for (i = 0; i < 6; ++i) { eth_hw_addr_set(dev, addr);
dev->dev_addr[i] = p[i];
}
/* load up the hardware address */ /* load up the hardware address */
pWord16 = (const unsigned short *)dev->dev_addr; pWord16 = (const unsigned short *)dev->dev_addr;
bmwrite(dev, MADD0, *pWord16++); bmwrite(dev, MADD0, *pWord16++);
......
...@@ -349,8 +349,7 @@ parse_eeprom (struct net_device *dev) ...@@ -349,8 +349,7 @@ parse_eeprom (struct net_device *dev)
} }
/* Set MAC address */ /* Set MAC address */
for (i = 0; i < 6; i++) eth_hw_addr_set(dev, psrom->mac_addr);
dev->dev_addr[i] = psrom->mac_addr[i];
if (np->chip_id == CHIP_IP1000A) { if (np->chip_id == CHIP_IP1000A) {
np->led_mode = psrom->led_mode; np->led_mode = psrom->led_mode;
......
...@@ -468,8 +468,7 @@ static int fmvj18x_config(struct pcmcia_device *link) ...@@ -468,8 +468,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
goto failed; goto failed;
} }
/* Read MACID from CIS */ /* Read MACID from CIS */
for (i = 0; i < 6; i++) eth_hw_addr_set(dev, &buf[5]);
dev->dev_addr[i] = buf[i + 5];
kfree(buf); kfree(buf);
} else { } else {
if (pcmcia_get_mac_from_cis(link, dev)) if (pcmcia_get_mac_from_cis(link, dev))
...@@ -499,9 +498,7 @@ static int fmvj18x_config(struct pcmcia_device *link) ...@@ -499,9 +498,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
pr_notice("unable to read hardware net address\n"); pr_notice("unable to read hardware net address\n");
goto failed; goto failed;
} }
for (i = 0 ; i < 6; i++) { eth_hw_addr_set(dev, buggybuf);
dev->dev_addr[i] = buggybuf[i];
}
card_name = "FMV-J182"; card_name = "FMV-J182";
break; break;
case MBH10302: case MBH10302:
......
...@@ -339,14 +339,13 @@ static const struct net_device_ops sun3_82586_netdev_ops = { ...@@ -339,14 +339,13 @@ static const struct net_device_ops sun3_82586_netdev_ops = {
static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr) static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
{ {
int i, size, retval; int size, retval;
if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME)) if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME))
return -EBUSY; return -EBUSY;
/* copy in the ethernet address from the prom */ /* copy in the ethernet address from the prom */
for(i = 0; i < 6 ; i++) eth_hw_addr_set(dev, idprom->id_ethaddr);
dev->dev_addr[i] = idprom->id_ethaddr[i];
printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr); printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);
......
...@@ -3739,7 +3739,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3739,7 +3739,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct net_device *netdev; struct net_device *netdev;
struct myri10ge_priv *mgp; struct myri10ge_priv *mgp;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int i;
int status = -ENXIO; int status = -ENXIO;
int dac_enabled; int dac_enabled;
unsigned hdr_offset, ss_offset; unsigned hdr_offset, ss_offset;
...@@ -3829,8 +3828,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3829,8 +3828,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (status) if (status)
goto abort_with_ioremap; goto abort_with_ioremap;
for (i = 0; i < ETH_ALEN; i++) eth_hw_addr_set(netdev, mgp->mac_addr);
netdev->dev_addr[i] = mgp->mac_addr[i];
myri10ge_select_firmware(mgp); myri10ge_select_firmware(mgp);
......
...@@ -666,14 +666,13 @@ static int pcmcia_osi_mac(struct pcmcia_device *p_dev, ...@@ -666,14 +666,13 @@ static int pcmcia_osi_mac(struct pcmcia_device *p_dev,
void *priv) void *priv)
{ {
struct net_device *dev = priv; struct net_device *dev = priv;
int i;
if (tuple->TupleDataLen < 8) if (tuple->TupleDataLen < 8)
return -EINVAL; return -EINVAL;
if (tuple->TupleData[0] != 0x04) if (tuple->TupleData[0] != 0x04)
return -EINVAL; return -EINVAL;
for (i = 0; i < 6; i++)
dev->dev_addr[i] = tuple->TupleData[i+2]; eth_hw_addr_set(dev, &tuple->TupleData[2]);
return 0; return 0;
}; };
......
...@@ -1076,7 +1076,6 @@ static int bigmac_ether_init(struct platform_device *op, ...@@ -1076,7 +1076,6 @@ static int bigmac_ether_init(struct platform_device *op,
struct net_device *dev; struct net_device *dev;
u8 bsizes, bsizes_more; u8 bsizes, bsizes_more;
struct bigmac *bp; struct bigmac *bp;
int i;
/* Get a new device struct for this interface. */ /* Get a new device struct for this interface. */
dev = alloc_etherdev(sizeof(struct bigmac)); dev = alloc_etherdev(sizeof(struct bigmac));
...@@ -1086,8 +1085,7 @@ static int bigmac_ether_init(struct platform_device *op, ...@@ -1086,8 +1085,7 @@ static int bigmac_ether_init(struct platform_device *op,
if (version_printed++ == 0) if (version_printed++ == 0)
printk(KERN_INFO "%s", version); printk(KERN_INFO "%s", version);
for (i = 0; i < 6; i++) eth_hw_addr_set(dev, idprom->id_ethaddr);
dev->dev_addr[i] = idprom->id_ethaddr[i];
/* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */ /* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */
bp = netdev_priv(dev); bp = netdev_priv(dev);
......
...@@ -1402,7 +1402,6 @@ static int match_first_device(struct device *dev, const void *data) ...@@ -1402,7 +1402,6 @@ static int match_first_device(struct device *dev, const void *data)
static int emac_dev_open(struct net_device *ndev) static int emac_dev_open(struct net_device *ndev)
{ {
struct device *emac_dev = &ndev->dev; struct device *emac_dev = &ndev->dev;
u32 cnt;
struct resource *res; struct resource *res;
int q, m, ret; int q, m, ret;
int res_num = 0, irq_num = 0; int res_num = 0, irq_num = 0;
...@@ -1420,8 +1419,7 @@ static int emac_dev_open(struct net_device *ndev) ...@@ -1420,8 +1419,7 @@ static int emac_dev_open(struct net_device *ndev)
} }
netif_carrier_off(ndev); netif_carrier_off(ndev);
for (cnt = 0; cnt < ETH_ALEN; cnt++) eth_hw_addr_set(ndev, priv->mac_addr);
ndev->dev_addr[cnt] = priv->mac_addr[cnt];
/* Configuration items */ /* Configuration items */
priv->rx_buf_size = EMAC_DEF_MAX_FRAME_SIZE + NET_IP_ALIGN; priv->rx_buf_size = EMAC_DEF_MAX_FRAME_SIZE + NET_IP_ALIGN;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <pcmcia/cisreg.h> #include <pcmcia/cisreg.h>
#include <pcmcia/cistpl.h> #include <pcmcia/cistpl.h>
...@@ -398,7 +399,6 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple, ...@@ -398,7 +399,6 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
void *priv) void *priv)
{ {
struct net_device *dev = priv; struct net_device *dev = priv;
int i;
if (tuple->TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID) if (tuple->TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID)
return -EINVAL; return -EINVAL;
...@@ -412,8 +412,7 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple, ...@@ -412,8 +412,7 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
dev_warn(&p_dev->dev, "Invalid header for LAN_NODE_ID\n"); dev_warn(&p_dev->dev, "Invalid header for LAN_NODE_ID\n");
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < 6; i++) eth_hw_addr_set(dev, &tuple->TupleData[2]);
dev->dev_addr[i] = tuple->TupleData[i+2];
return 0; return 0;
} }
......
...@@ -355,8 +355,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -355,8 +355,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type); pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
switch (mesg->type) { switch (mesg->type) {
case l_set_mac_addr: case l_set_mac_addr:
for (i = 0; i < 6; i++) eth_hw_addr_set(dev, mesg->content.normal.mac_addr);
dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
break; break;
case l_del_mac_addr: case l_del_mac_addr:
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment