Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <kuba@kernel.org>

+17 -38
+1 -3
drivers/net/ethernet/amd/sun3lance.c
··· 305 305 unsigned long ioaddr; 306 306 307 307 struct lance_private *lp; 308 - int i; 309 308 static int did_version; 310 309 volatile unsigned short *ioaddr_probe; 311 310 unsigned short tmp1, tmp2; ··· 372 373 dev->irq); 373 374 374 375 /* copy in the ethernet address from the prom */ 375 - for(i = 0; i < 6 ; i++) 376 - dev->dev_addr[i] = idprom->id_ethaddr[i]; 376 + eth_hw_addr_set(dev, idprom->id_ethaddr); 377 377 378 378 /* tell the card it's ether address, bytes swapped */ 379 379 MEM->init.hwaddr[0] = dev->dev_addr[1];
+1 -3
drivers/net/ethernet/amd/sunlance.c
··· 1301 1301 struct device_node *dp = op->dev.of_node; 1302 1302 struct lance_private *lp; 1303 1303 struct net_device *dev; 1304 - int i; 1305 1304 1306 1305 dev = alloc_etherdev(sizeof(struct lance_private) + 8); 1307 1306 if (!dev) ··· 1314 1315 * will copy the address in the device structure to the lance 1315 1316 * initialization block. 1316 1317 */ 1317 - for (i = 0; i < 6; i++) 1318 - dev->dev_addr[i] = idprom->id_ethaddr[i]; 1318 + eth_hw_addr_set(dev, idprom->id_ethaddr); 1319 1319 1320 1320 /* Get the IO region */ 1321 1321 lp->lregs = of_ioremap(&op->resource[0], 0,
+2 -5
drivers/net/ethernet/apple/bmac.c
··· 521 521 static int bmac_set_address(struct net_device *dev, void *addr) 522 522 { 523 523 struct bmac_data *bp = netdev_priv(dev); 524 - unsigned char *p = addr; 525 524 const unsigned short *pWord16; 526 525 unsigned long flags; 527 - int i; 528 526 529 527 XXDEBUG(("bmac: enter set_address\n")); 530 528 spin_lock_irqsave(&bp->lock, flags); 531 529 532 - for (i = 0; i < 6; ++i) { 533 - dev->dev_addr[i] = p[i]; 534 - } 530 + eth_hw_addr_set(dev, addr); 531 + 535 532 /* load up the hardware address */ 536 533 pWord16 = (const unsigned short *)dev->dev_addr; 537 534 bmwrite(dev, MADD0, *pWord16++);
+1 -2
drivers/net/ethernet/dlink/dl2k.c
··· 349 349 } 350 350 351 351 /* 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); 354 353 355 354 if (np->chip_id == CHIP_IP1000A) { 356 355 np->led_mode = psrom->led_mode;
+2 -5
drivers/net/ethernet/fujitsu/fmvj18x_cs.c
··· 468 468 goto failed; 469 469 } 470 470 /* 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]); 473 472 kfree(buf); 474 473 } else { 475 474 if (pcmcia_get_mac_from_cis(link, dev)) ··· 498 499 pr_notice("unable to read hardware net address\n"); 499 500 goto failed; 500 501 } 501 - for (i = 0 ; i < 6; i++) { 502 - dev->dev_addr[i] = buggybuf[i]; 503 - } 502 + eth_hw_addr_set(dev, buggybuf); 504 503 card_name = "FMV-J182"; 505 504 break; 506 505 case MBH10302:
+2 -3
drivers/net/ethernet/i825xx/sun3_82586.c
··· 339 339 340 340 static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr) 341 341 { 342 - int i, size, retval; 342 + int size, retval; 343 343 344 344 if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME)) 345 345 return -EBUSY; 346 346 347 347 /* 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); 350 349 351 350 printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr); 352 351
+1 -3
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
··· 3739 3739 struct net_device *netdev; 3740 3740 struct myri10ge_priv *mgp; 3741 3741 struct device *dev = &pdev->dev; 3742 - int i; 3743 3742 int status = -ENXIO; 3744 3743 int dac_enabled; 3745 3744 unsigned hdr_offset, ss_offset; ··· 3828 3829 if (status) 3829 3830 goto abort_with_ioremap; 3830 3831 3831 - for (i = 0; i < ETH_ALEN; i++) 3832 - netdev->dev_addr[i] = mgp->mac_addr[i]; 3832 + eth_hw_addr_set(netdev, mgp->mac_addr); 3833 3833 3834 3834 myri10ge_select_firmware(mgp); 3835 3835
+2 -3
drivers/net/ethernet/smsc/smc91c92_cs.c
··· 666 666 void *priv) 667 667 { 668 668 struct net_device *dev = priv; 669 - int i; 670 669 671 670 if (tuple->TupleDataLen < 8) 672 671 return -EINVAL; 673 672 if (tuple->TupleData[0] != 0x04) 674 673 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]); 677 676 return 0; 678 677 }; 679 678
+1 -3
drivers/net/ethernet/sun/sunbmac.c
··· 1076 1076 struct net_device *dev; 1077 1077 u8 bsizes, bsizes_more; 1078 1078 struct bigmac *bp; 1079 - int i; 1080 1079 1081 1080 /* Get a new device struct for this interface. */ 1082 1081 dev = alloc_etherdev(sizeof(struct bigmac)); ··· 1085 1086 if (version_printed++ == 0) 1086 1087 printk(KERN_INFO "%s", version); 1087 1088 1088 - for (i = 0; i < 6; i++) 1089 - dev->dev_addr[i] = idprom->id_ethaddr[i]; 1089 + eth_hw_addr_set(dev, idprom->id_ethaddr); 1090 1090 1091 1091 /* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */ 1092 1092 bp = netdev_priv(dev);
+1 -3
drivers/net/ethernet/ti/davinci_emac.c
··· 1402 1402 static int emac_dev_open(struct net_device *ndev) 1403 1403 { 1404 1404 struct device *emac_dev = &ndev->dev; 1405 - u32 cnt; 1406 1405 struct resource *res; 1407 1406 int q, m, ret; 1408 1407 int res_num = 0, irq_num = 0; ··· 1419 1420 } 1420 1421 1421 1422 netif_carrier_off(ndev); 1422 - for (cnt = 0; cnt < ETH_ALEN; cnt++) 1423 - ndev->dev_addr[cnt] = priv->mac_addr[cnt]; 1423 + eth_hw_addr_set(ndev, priv->mac_addr); 1424 1424 1425 1425 /* Configuration items */ 1426 1426 priv->rx_buf_size = EMAC_DEF_MAX_FRAME_SIZE + NET_IP_ALIGN;
+2 -3
drivers/pcmcia/pcmcia_cis.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/kernel.h> 16 16 #include <linux/netdevice.h> 17 + #include <linux/etherdevice.h> 17 18 18 19 #include <pcmcia/cisreg.h> 19 20 #include <pcmcia/cistpl.h> ··· 399 398 void *priv) 400 399 { 401 400 struct net_device *dev = priv; 402 - int i; 403 401 404 402 if (tuple->TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID) 405 403 return -EINVAL; ··· 412 412 dev_warn(&p_dev->dev, "Invalid header for LAN_NODE_ID\n"); 413 413 return -EINVAL; 414 414 } 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]); 417 416 return 0; 418 417 } 419 418
+1 -2
net/atm/lec.c
··· 355 355 pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type); 356 356 switch (mesg->type) { 357 357 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); 360 359 break; 361 360 case l_del_mac_addr: 362 361 for (i = 0; i < 6; i++)