Skip to content

Commit 562ef98

Browse files
committed
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: Jakub Kicinski <[email protected]>
1 parent 68a0640 commit 562ef98

File tree

12 files changed

+17
-38
lines changed

12 files changed

+17
-38
lines changed

drivers/net/ethernet/amd/sun3lance.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ static int __init lance_probe( struct net_device *dev)
305305
unsigned long ioaddr;
306306

307307
struct lance_private *lp;
308-
int i;
309308
static int did_version;
310309
volatile unsigned short *ioaddr_probe;
311310
unsigned short tmp1, tmp2;
@@ -373,8 +372,7 @@ static int __init lance_probe( struct net_device *dev)
373372
dev->irq);
374373

375374
/* copy in the ethernet address from the prom */
376-
for(i = 0; i < 6 ; i++)
377-
dev->dev_addr[i] = idprom->id_ethaddr[i];
375+
eth_hw_addr_set(dev, idprom->id_ethaddr);
378376

379377
/* tell the card it's ether address, bytes swapped */
380378
MEM->init.hwaddr[0] = dev->dev_addr[1];

drivers/net/ethernet/amd/sunlance.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,6 @@ static int sparc_lance_probe_one(struct platform_device *op,
13011301
struct device_node *dp = op->dev.of_node;
13021302
struct lance_private *lp;
13031303
struct net_device *dev;
1304-
int i;
13051304

13061305
dev = alloc_etherdev(sizeof(struct lance_private) + 8);
13071306
if (!dev)
@@ -1315,8 +1314,7 @@ static int sparc_lance_probe_one(struct platform_device *op,
13151314
* will copy the address in the device structure to the lance
13161315
* initialization block.
13171316
*/
1318-
for (i = 0; i < 6; i++)
1319-
dev->dev_addr[i] = idprom->id_ethaddr[i];
1317+
eth_hw_addr_set(dev, idprom->id_ethaddr);
13201318

13211319
/* Get the IO region */
13221320
lp->lregs = of_ioremap(&op->resource[0], 0,

drivers/net/ethernet/apple/bmac.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,14 @@ static int bmac_resume(struct macio_dev *mdev)
521521
static int bmac_set_address(struct net_device *dev, void *addr)
522522
{
523523
struct bmac_data *bp = netdev_priv(dev);
524-
unsigned char *p = addr;
525524
const unsigned short *pWord16;
526525
unsigned long flags;
527-
int i;
528526

529527
XXDEBUG(("bmac: enter set_address\n"));
530528
spin_lock_irqsave(&bp->lock, flags);
531529

532-
for (i = 0; i < 6; ++i) {
533-
dev->dev_addr[i] = p[i];
534-
}
530+
eth_hw_addr_set(dev, addr);
531+
535532
/* load up the hardware address */
536533
pWord16 = (const unsigned short *)dev->dev_addr;
537534
bmwrite(dev, MADD0, *pWord16++);

drivers/net/ethernet/dlink/dl2k.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ parse_eeprom (struct net_device *dev)
349349
}
350350

351351
/* Set MAC address */
352-
for (i = 0; i < 6; i++)
353-
dev->dev_addr[i] = psrom->mac_addr[i];
352+
eth_hw_addr_set(dev, psrom->mac_addr);
354353

355354
if (np->chip_id == CHIP_IP1000A) {
356355
np->led_mode = psrom->led_mode;

drivers/net/ethernet/fujitsu/fmvj18x_cs.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
468468
goto failed;
469469
}
470470
/* Read MACID from CIS */
471-
for (i = 0; i < 6; i++)
472-
dev->dev_addr[i] = buf[i + 5];
471+
eth_hw_addr_set(dev, &buf[5]);
473472
kfree(buf);
474473
} else {
475474
if (pcmcia_get_mac_from_cis(link, dev))
@@ -499,9 +498,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
499498
pr_notice("unable to read hardware net address\n");
500499
goto failed;
501500
}
502-
for (i = 0 ; i < 6; i++) {
503-
dev->dev_addr[i] = buggybuf[i];
504-
}
501+
eth_hw_addr_set(dev, buggybuf);
505502
card_name = "FMV-J182";
506503
break;
507504
case MBH10302:

drivers/net/ethernet/i825xx/sun3_82586.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,13 @@ static const struct net_device_ops sun3_82586_netdev_ops = {
339339

340340
static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
341341
{
342-
int i, size, retval;
342+
int size, retval;
343343

344344
if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME))
345345
return -EBUSY;
346346

347347
/* copy in the ethernet address from the prom */
348-
for(i = 0; i < 6 ; i++)
349-
dev->dev_addr[i] = idprom->id_ethaddr[i];
348+
eth_hw_addr_set(dev, idprom->id_ethaddr);
350349

351350
printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);
352351

drivers/net/ethernet/myricom/myri10ge/myri10ge.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3739,7 +3739,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
37393739
struct net_device *netdev;
37403740
struct myri10ge_priv *mgp;
37413741
struct device *dev = &pdev->dev;
3742-
int i;
37433742
int status = -ENXIO;
37443743
int dac_enabled;
37453744
unsigned hdr_offset, ss_offset;
@@ -3829,8 +3828,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
38293828
if (status)
38303829
goto abort_with_ioremap;
38313830

3832-
for (i = 0; i < ETH_ALEN; i++)
3833-
netdev->dev_addr[i] = mgp->mac_addr[i];
3831+
eth_hw_addr_set(netdev, mgp->mac_addr);
38343832

38353833
myri10ge_select_firmware(mgp);
38363834

drivers/net/ethernet/smsc/smc91c92_cs.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,13 @@ static int pcmcia_osi_mac(struct pcmcia_device *p_dev,
666666
void *priv)
667667
{
668668
struct net_device *dev = priv;
669-
int i;
670669

671670
if (tuple->TupleDataLen < 8)
672671
return -EINVAL;
673672
if (tuple->TupleData[0] != 0x04)
674673
return -EINVAL;
675-
for (i = 0; i < 6; i++)
676-
dev->dev_addr[i] = tuple->TupleData[i+2];
674+
675+
eth_hw_addr_set(dev, &tuple->TupleData[2]);
677676
return 0;
678677
};
679678

drivers/net/ethernet/sun/sunbmac.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,6 @@ static int bigmac_ether_init(struct platform_device *op,
10761076
struct net_device *dev;
10771077
u8 bsizes, bsizes_more;
10781078
struct bigmac *bp;
1079-
int i;
10801079

10811080
/* Get a new device struct for this interface. */
10821081
dev = alloc_etherdev(sizeof(struct bigmac));
@@ -1086,8 +1085,7 @@ static int bigmac_ether_init(struct platform_device *op,
10861085
if (version_printed++ == 0)
10871086
printk(KERN_INFO "%s", version);
10881087

1089-
for (i = 0; i < 6; i++)
1090-
dev->dev_addr[i] = idprom->id_ethaddr[i];
1088+
eth_hw_addr_set(dev, idprom->id_ethaddr);
10911089

10921090
/* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */
10931091
bp = netdev_priv(dev);

drivers/net/ethernet/ti/davinci_emac.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,6 @@ static int match_first_device(struct device *dev, const void *data)
14021402
static int emac_dev_open(struct net_device *ndev)
14031403
{
14041404
struct device *emac_dev = &ndev->dev;
1405-
u32 cnt;
14061405
struct resource *res;
14071406
int q, m, ret;
14081407
int res_num = 0, irq_num = 0;
@@ -1420,8 +1419,7 @@ static int emac_dev_open(struct net_device *ndev)
14201419
}
14211420

14221421
netif_carrier_off(ndev);
1423-
for (cnt = 0; cnt < ETH_ALEN; cnt++)
1424-
ndev->dev_addr[cnt] = priv->mac_addr[cnt];
1422+
eth_hw_addr_set(ndev, priv->mac_addr);
14251423

14261424
/* Configuration items */
14271425
priv->rx_buf_size = EMAC_DEF_MAX_FRAME_SIZE + NET_IP_ALIGN;

drivers/pcmcia/pcmcia_cis.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/module.h>
1515
#include <linux/kernel.h>
1616
#include <linux/netdevice.h>
17+
#include <linux/etherdevice.h>
1718

1819
#include <pcmcia/cisreg.h>
1920
#include <pcmcia/cistpl.h>
@@ -398,7 +399,6 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
398399
void *priv)
399400
{
400401
struct net_device *dev = priv;
401-
int i;
402402

403403
if (tuple->TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID)
404404
return -EINVAL;
@@ -412,8 +412,7 @@ static int pcmcia_do_get_mac(struct pcmcia_device *p_dev, tuple_t *tuple,
412412
dev_warn(&p_dev->dev, "Invalid header for LAN_NODE_ID\n");
413413
return -EINVAL;
414414
}
415-
for (i = 0; i < 6; i++)
416-
dev->dev_addr[i] = tuple->TupleData[i+2];
415+
eth_hw_addr_set(dev, &tuple->TupleData[2]);
417416
return 0;
418417
}
419418

net/atm/lec.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
355355
pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
356356
switch (mesg->type) {
357357
case l_set_mac_addr:
358-
for (i = 0; i < 6; i++)
359-
dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
358+
eth_hw_addr_set(dev, mesg->content.normal.mac_addr);
360359
break;
361360
case l_del_mac_addr:
362361
for (i = 0; i < 6; i++)

0 commit comments

Comments
 (0)