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

ethernet: use eth_hw_addr_set() in unmaintained drivers

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jakub Kicinski and committed by
David S. Miller
4abd7cff 0e9e7598

+99 -53
+3 -1
drivers/net/ethernet/calxeda/xgmac.c
··· 1693 1693 struct resource *res; 1694 1694 struct net_device *ndev = NULL; 1695 1695 struct xgmac_priv *priv = NULL; 1696 + u8 addr[ETH_ALEN]; 1696 1697 u32 uid; 1697 1698 1698 1699 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 1786 1785 ndev->max_mtu = XGMAC_MAX_MTU; 1787 1786 1788 1787 /* Get the MAC address */ 1789 - xgmac_get_mac_addr(priv->base, ndev->dev_addr, 0); 1788 + xgmac_get_mac_addr(priv->base, addr, 0); 1789 + eth_hw_addr_set(ndev, addr); 1790 1790 if (!is_valid_ether_addr(ndev->dev_addr)) 1791 1791 netdev_warn(ndev, "MAC address %pM not valid", 1792 1792 ndev->dev_addr);
+7 -4
drivers/net/ethernet/cirrus/cs89x0.c
··· 1314 1314 int tmp; 1315 1315 unsigned rev_type = 0; 1316 1316 int eeprom_buff[CHKSUM_LEN]; 1317 + u8 addr[ETH_ALEN]; 1317 1318 int retval; 1318 1319 1319 1320 /* Initialize the device structure. */ ··· 1388 1387 for (i = 0; i < ETH_ALEN / 2; i++) { 1389 1388 unsigned int Addr; 1390 1389 Addr = readreg(dev, PP_IA + i * 2); 1391 - dev->dev_addr[i * 2] = Addr & 0xFF; 1392 - dev->dev_addr[i * 2 + 1] = Addr >> 8; 1390 + addr[i * 2] = Addr & 0xFF; 1391 + addr[i * 2 + 1] = Addr >> 8; 1393 1392 } 1393 + eth_hw_addr_set(dev, addr); 1394 1394 1395 1395 /* Load the Adapter Configuration. 1396 1396 * Note: Barring any more specific information from some ··· 1466 1464 /* eeprom_buff has 32-bit ints, so we can't just memcpy it */ 1467 1465 /* store the initial memory base address */ 1468 1466 for (i = 0; i < ETH_ALEN / 2; i++) { 1469 - dev->dev_addr[i * 2] = eeprom_buff[i]; 1470 - dev->dev_addr[i * 2 + 1] = eeprom_buff[i] >> 8; 1467 + addr[i * 2] = eeprom_buff[i]; 1468 + addr[i * 2 + 1] = eeprom_buff[i] >> 8; 1471 1469 } 1470 + eth_hw_addr_set(dev, addr); 1472 1471 cs89_dbg(1, debug, "%s: new adapter_cnf: 0x%x\n", 1473 1472 dev->name, lp->adapter_cnf); 1474 1473 }
+5 -2
drivers/net/ethernet/davicom/dm9000.c
··· 1425 1425 enum of_gpio_flags flags; 1426 1426 struct regulator *power; 1427 1427 bool inv_mac_addr = false; 1428 + u8 addr[ETH_ALEN]; 1428 1429 1429 1430 power = devm_regulator_get(dev, "vcc"); 1430 1431 if (IS_ERR(power)) { ··· 1667 1666 1668 1667 /* try reading the node address from the attached EEPROM */ 1669 1668 for (i = 0; i < 6; i += 2) 1670 - dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i); 1669 + dm9000_read_eeprom(db, i / 2, addr + i); 1670 + eth_hw_addr_set(ndev, addr); 1671 1671 1672 1672 if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) { 1673 1673 mac_src = "platform data"; ··· 1680 1678 1681 1679 mac_src = "chip"; 1682 1680 for (i = 0; i < 6; i++) 1683 - ndev->dev_addr[i] = ior(db, i+DM9000_PAR); 1681 + addr[i] = ior(db, i + DM9000_PAR); 1682 + eth_hw_addr_set(ndev, pdata->dev_addr); 1684 1683 } 1685 1684 1686 1685 if (!is_valid_ether_addr(ndev->dev_addr)) {
+6 -2
drivers/net/ethernet/ethoc.c
··· 1154 1154 /* Check that the given MAC address is valid. If it isn't, read the 1155 1155 * current MAC from the controller. 1156 1156 */ 1157 - if (!is_valid_ether_addr(netdev->dev_addr)) 1158 - ethoc_get_mac_address(netdev, netdev->dev_addr); 1157 + if (!is_valid_ether_addr(netdev->dev_addr)) { 1158 + u8 addr[ETH_ALEN]; 1159 + 1160 + ethoc_get_mac_address(netdev, addr); 1161 + eth_hw_addr_set(netdev, addr); 1162 + } 1159 1163 1160 1164 /* Check the MAC again for validity, if it still isn't choose and 1161 1165 * program a random one.
+3 -1
drivers/net/ethernet/fealnx.c
··· 482 482 struct net_device *dev; 483 483 void *ring_space; 484 484 dma_addr_t ring_dma; 485 + u8 addr[ETH_ALEN]; 485 486 #ifdef USE_IO_OPS 486 487 int bar = 0; 487 488 #else ··· 526 525 527 526 /* read ethernet id */ 528 527 for (i = 0; i < 6; ++i) 529 - dev->dev_addr[i] = ioread8(ioaddr + PAR0 + i); 528 + addr[i] = ioread8(ioaddr + PAR0 + i); 529 + eth_hw_addr_set(dev, addr); 530 530 531 531 /* Reset the chip to erase previous misconfiguration. */ 532 532 iowrite32(0x00000001, ioaddr + BCR);
+5 -2
drivers/net/ethernet/fujitsu/fmvj18x_cs.c
··· 334 334 u8 *buf; 335 335 size_t len; 336 336 u_char buggybuf[32]; 337 + u8 addr[ETH_ALEN]; 337 338 338 339 dev_dbg(&link->dev, "fmvj18x_config\n"); 339 340 ··· 490 489 case UNGERMANN: 491 490 /* Read MACID from register */ 492 491 for (i = 0; i < 6; i++) 493 - dev->dev_addr[i] = inb(ioaddr + UNGERMANN_MAC_ID + i); 492 + addr[i] = inb(ioaddr + UNGERMANN_MAC_ID + i); 493 + eth_hw_addr_set(dev, addr); 494 494 card_name = "Access/CARD"; 495 495 break; 496 496 case XXX10304: ··· 507 505 default: 508 506 /* Read MACID from register */ 509 507 for (i = 0; i < 6; i++) 510 - dev->dev_addr[i] = inb(ioaddr + MAC_ID + i); 508 + addr[i] = inb(ioaddr + MAC_ID + i); 509 + eth_hw_addr_set(dev, addr); 511 510 card_name = "FMV-J181"; 512 511 break; 513 512 }
+3 -1
drivers/net/ethernet/huawei/hinic/hinic_main.c
··· 1181 1181 struct net_device *netdev; 1182 1182 struct hinic_hwdev *hwdev; 1183 1183 struct devlink *devlink; 1184 + u8 addr[ETH_ALEN]; 1184 1185 int err, num_qps; 1185 1186 1186 1187 devlink = hinic_devlink_alloc(&pdev->dev); ··· 1260 1259 1261 1260 pci_set_drvdata(pdev, netdev); 1262 1261 1263 - err = hinic_port_get_mac(nic_dev, netdev->dev_addr); 1262 + err = hinic_port_get_mac(nic_dev, addr); 1264 1263 if (err) { 1265 1264 dev_err(&pdev->dev, "Failed to get mac address\n"); 1266 1265 goto err_get_mac; 1267 1266 } 1267 + eth_hw_addr_set(netdev, addr); 1268 1268 1269 1269 if (!is_valid_ether_addr(netdev->dev_addr)) { 1270 1270 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) {
+6 -2
drivers/net/ethernet/marvell/pxa168_eth.c
··· 1436 1436 1437 1437 err = of_get_ethdev_address(pdev->dev.of_node, dev); 1438 1438 if (err) { 1439 + u8 addr[ETH_ALEN]; 1440 + 1439 1441 /* try reading the mac address, if set by the bootloader */ 1440 - pxa168_eth_get_mac_address(dev, dev->dev_addr); 1441 - if (!is_valid_ether_addr(dev->dev_addr)) { 1442 + pxa168_eth_get_mac_address(dev, addr); 1443 + if (is_valid_ether_addr(addr)) { 1444 + eth_hw_addr_set(dev, addr); 1445 + } else { 1442 1446 dev_info(&pdev->dev, "Using random mac address\n"); 1443 1447 eth_hw_addr_random(dev); 1444 1448 }
+5 -3
drivers/net/ethernet/micrel/ks8842.c
··· 348 348 ks8842_write16(adapter, 32, 0x1, REG_SW_ID_AND_ENABLE); 349 349 } 350 350 351 - static void ks8842_read_mac_addr(struct ks8842_adapter *adapter, u8 *dest) 351 + static void ks8842_init_mac_addr(struct ks8842_adapter *adapter) 352 352 { 353 + u8 addr[ETH_ALEN]; 353 354 int i; 354 355 u16 mac; 355 356 356 357 for (i = 0; i < ETH_ALEN; i++) 357 - dest[ETH_ALEN - i - 1] = ks8842_read8(adapter, 2, REG_MARL + i); 358 + addr[ETH_ALEN - i - 1] = ks8842_read8(adapter, 2, REG_MARL + i); 359 + eth_hw_addr_set(adapter->netdev, addr); 358 360 359 361 if (adapter->conf_flags & MICREL_KS884X) { 360 362 /* ··· 1197 1195 } 1198 1196 1199 1197 if (i == netdev->addr_len) { 1200 - ks8842_read_mac_addr(adapter, netdev->dev_addr); 1198 + ks8842_init_mac_addr(adapter); 1201 1199 1202 1200 if (!is_valid_ether_addr(netdev->dev_addr)) 1203 1201 eth_hw_addr_random(netdev);
+4 -2
drivers/net/ethernet/micrel/ks8851_common.c
··· 165 165 { 166 166 struct ks8851_net *ks = netdev_priv(dev); 167 167 unsigned long flags; 168 + u8 addr[ETH_ALEN]; 168 169 u16 reg; 169 170 int i; 170 171 ··· 173 172 174 173 for (i = 0; i < ETH_ALEN; i += 2) { 175 174 reg = ks8851_rdreg16(ks, KS_MAR(i)); 176 - dev->dev_addr[i] = reg >> 8; 177 - dev->dev_addr[i + 1] = reg & 0xff; 175 + addr[i] = reg >> 8; 176 + addr[i + 1] = reg & 0xff; 178 177 } 178 + eth_hw_addr_set(dev, addr); 179 179 180 180 ks8851_unlock(ks, &flags); 181 181 }
+5 -2
drivers/net/ethernet/micrel/ksz884x.c
··· 7007 7007 if (MAIN_PORT == i) 7008 7008 eth_hw_addr_set(dev, hw_priv->hw.override_addr); 7009 7009 else { 7010 - eth_hw_addr_set(dev, sw->other_addr); 7010 + u8 addr[ETH_ALEN]; 7011 + 7012 + ether_addr_copy(addr, sw->other_addr); 7011 7013 if (ether_addr_equal(sw->other_addr, hw->override_addr)) 7012 - dev->dev_addr[5] += port->first_port; 7014 + addr[5] += port->first_port; 7015 + eth_hw_addr_set(dev, addr); 7013 7016 } 7014 7017 7015 7018 dev->netdev_ops = &netdev_ops;
+3 -1
drivers/net/ethernet/microchip/encx24j600.c
··· 1001 1001 struct net_device *ndev; 1002 1002 struct encx24j600_priv *priv; 1003 1003 u16 eidled; 1004 + u8 addr[ETH_ALEN]; 1004 1005 1005 1006 ndev = alloc_etherdev(sizeof(struct encx24j600_priv)); 1006 1007 ··· 1057 1056 } 1058 1057 1059 1058 /* Get the MAC address from the chip */ 1060 - encx24j600_hw_get_macaddr(priv, ndev->dev_addr); 1059 + encx24j600_hw_get_macaddr(priv, addr); 1060 + eth_hw_addr_set(ndev, addr); 1061 1061 1062 1062 ndev->ethtool_ops = &encx24j600_ethtool_ops; 1063 1063
+4 -2
drivers/net/ethernet/natsemi/natsemi.c
··· 809 809 unsigned long iosize; 810 810 void __iomem *ioaddr; 811 811 const int pcibar = 1; /* PCI base address register */ 812 + u8 addr[ETH_ALEN]; 812 813 int prev_eedata; 813 814 u32 tmp; 814 815 ··· 860 859 prev_eedata = eeprom_read(ioaddr, 6); 861 860 for (i = 0; i < 3; i++) { 862 861 int eedata = eeprom_read(ioaddr, i + 7); 863 - dev->dev_addr[i*2] = (eedata << 1) + (prev_eedata >> 15); 864 - dev->dev_addr[i*2+1] = eedata >> 7; 862 + addr[i*2] = (eedata << 1) + (prev_eedata >> 15); 863 + addr[i*2+1] = eedata >> 7; 865 864 prev_eedata = eedata; 866 865 } 866 + eth_hw_addr_set(dev, addr); 867 867 868 868 np = netdev_priv(dev); 869 869 np->ioaddr = ioaddr;
+7 -4
drivers/net/ethernet/natsemi/ns83820.c
··· 1649 1649 return ret; 1650 1650 } 1651 1651 1652 - static void ns83820_getmac(struct ns83820 *dev, u8 *mac) 1652 + static void ns83820_getmac(struct ns83820 *dev, struct net_device *ndev) 1653 1653 { 1654 + u8 mac[ETH_ALEN]; 1654 1655 unsigned i; 1656 + 1655 1657 for (i=0; i<3; i++) { 1656 1658 u32 data; 1657 1659 ··· 1663 1661 writel(i*2, dev->base + RFCR); 1664 1662 data = readl(dev->base + RFDR); 1665 1663 1666 - *mac++ = data; 1667 - *mac++ = data >> 8; 1664 + mac[i * 2] = data; 1665 + mac[i * 2 + 1] = data >> 8; 1668 1666 } 1667 + eth_hw_addr_set(ndev, mac); 1669 1668 } 1670 1669 1671 1670 static void ns83820_set_multicast(struct net_device *ndev) ··· 2139 2136 /* Disable Wake On Lan */ 2140 2137 writel(0, dev->base + WCSR); 2141 2138 2142 - ns83820_getmac(dev, ndev->dev_addr); 2139 + ns83820_getmac(dev, ndev); 2143 2140 2144 2141 /* Yes, we support dumb IP checksum on transmit */ 2145 2142 ndev->features |= NETIF_F_SG;
+3 -2
drivers/net/ethernet/packetengines/hamachi.c
··· 592 592 void *ring_space; 593 593 dma_addr_t ring_dma; 594 594 int ret = -ENOMEM; 595 + u8 addr[ETH_ALEN]; 595 596 596 597 /* when built into the kernel, we only print version if device is found */ 597 598 #ifndef MODULE ··· 629 628 SET_NETDEV_DEV(dev, &pdev->dev); 630 629 631 630 for (i = 0; i < 6; i++) 632 - dev->dev_addr[i] = 1 ? read_eeprom(ioaddr, 4 + i) 633 - : readb(ioaddr + StationAddr + i); 631 + addr[i] = read_eeprom(ioaddr, 4 + i); 632 + eth_hw_addr_set(dev, addr); 634 633 635 634 #if ! defined(final_version) 636 635 if (hamachi_debug > 4)
+4 -2
drivers/net/ethernet/packetengines/yellowfin.c
··· 384 384 #else 385 385 int bar = 1; 386 386 #endif 387 + u8 addr[ETH_ALEN]; 387 388 388 389 /* when built into the kernel, we only print version if device is found */ 389 390 #ifndef MODULE ··· 417 416 418 417 if (drv_flags & DontUseEeprom) 419 418 for (i = 0; i < 6; i++) 420 - dev->dev_addr[i] = ioread8(ioaddr + StnAddr + i); 419 + addr[i] = ioread8(ioaddr + StnAddr + i); 421 420 else { 422 421 int ee_offset = (read_eeprom(ioaddr, 6) == 0xff ? 0x100 : 0); 423 422 for (i = 0; i < 6; i++) 424 - dev->dev_addr[i] = read_eeprom(ioaddr, ee_offset + i); 423 + addr[i] = read_eeprom(ioaddr, ee_offset + i); 425 424 } 425 + eth_hw_addr_set(dev, addr); 426 426 427 427 /* Reset the chip. */ 428 428 iowrite32(0x80000000, ioaddr + DMACtrl);
+8 -6
drivers/net/ethernet/silan/sc92031.c
··· 1400 1400 void __iomem* port_base; 1401 1401 struct net_device *dev; 1402 1402 struct sc92031_priv *priv; 1403 + u8 addr[ETH_ALEN]; 1403 1404 u32 mac0, mac1; 1404 1405 1405 1406 err = pci_enable_device(pdev); ··· 1459 1458 1460 1459 mac0 = ioread32(port_base + MAC0); 1461 1460 mac1 = ioread32(port_base + MAC0 + 4); 1462 - dev->dev_addr[0] = mac0 >> 24; 1463 - dev->dev_addr[1] = mac0 >> 16; 1464 - dev->dev_addr[2] = mac0 >> 8; 1465 - dev->dev_addr[3] = mac0; 1466 - dev->dev_addr[4] = mac1 >> 8; 1467 - dev->dev_addr[5] = mac1; 1461 + addr[0] = mac0 >> 24; 1462 + addr[1] = mac0 >> 16; 1463 + addr[2] = mac0 >> 8; 1464 + addr[3] = mac0; 1465 + addr[4] = mac1 >> 8; 1466 + addr[5] = mac1; 1467 + eth_hw_addr_set(dev, addr); 1468 1468 1469 1469 err = register_netdev(dev); 1470 1470 if (err < 0)
+7 -3
drivers/net/ethernet/smsc/smc91c92_cs.c
··· 347 347 348 348 static int cvt_ascii_address(struct net_device *dev, char *s) 349 349 { 350 + u8 mac[ETH_ALEN]; 350 351 int i, j, da, c; 351 352 352 353 if (strlen(s) != 12) ··· 360 359 da += ((c >= '0') && (c <= '9')) ? 361 360 (c - '0') : ((c & 0x0f) + 9); 362 361 } 363 - dev->dev_addr[i] = da; 362 + mac[i] = da; 364 363 } 364 + eth_hw_addr_set(dev, mac); 365 365 return 0; 366 366 } 367 367 ··· 541 539 struct net_device *dev = link->priv; 542 540 unsigned int ioaddr = dev->base_addr; 543 541 int i, wait, loop; 542 + u8 mac[ETH_ALEN]; 544 543 u_int addr; 545 544 546 545 /* Read Ethernet address from Serial EEPROM */ ··· 562 559 return -1; 563 560 564 561 addr = inw(ioaddr + GENERAL); 565 - dev->dev_addr[2*i] = addr & 0xff; 566 - dev->dev_addr[2*i+1] = (addr >> 8) & 0xff; 562 + mac[2*i] = addr & 0xff; 563 + mac[2*i+1] = (addr >> 8) & 0xff; 567 564 } 565 + eth_hw_addr_set(dev, mac); 568 566 569 567 return 0; 570 568 }
+3 -1
drivers/net/ethernet/sun/sunvnet.c
··· 285 285 struct vio_dev *vdev) 286 286 { 287 287 struct net_device *dev; 288 + u8 addr[ETH_ALEN]; 288 289 struct vnet *vp; 289 290 int err, i; 290 291 ··· 296 295 dev->needed_tailroom = 8; 297 296 298 297 for (i = 0; i < ETH_ALEN; i++) 299 - dev->dev_addr[i] = (*local_mac >> (5 - i) * 8) & 0xff; 298 + addr[i] = (*local_mac >> (5 - i) * 8) & 0xff; 299 + eth_hw_addr_set(dev, addr); 300 300 301 301 vp = netdev_priv(dev); 302 302
+4 -2
drivers/net/ethernet/toshiba/tc35815.c
··· 725 725 { 726 726 struct tc35815_regs __iomem *tr = 727 727 (struct tc35815_regs __iomem *)dev->base_addr; 728 + u8 addr[ETH_ALEN]; 728 729 int i; 729 730 730 731 while (tc_readl(&tr->PROM_Ctl) & PROM_Busy) ··· 736 735 while (tc_readl(&tr->PROM_Ctl) & PROM_Busy) 737 736 ; 738 737 data = tc_readl(&tr->PROM_Data); 739 - dev->dev_addr[i] = data & 0xff; 740 - dev->dev_addr[i+1] = data >> 8; 738 + addr[i] = data & 0xff; 739 + addr[i+1] = data >> 8; 741 740 } 741 + eth_hw_addr_set(dev, addr); 742 742 if (!is_valid_ether_addr(dev->dev_addr)) 743 743 return tc35815_read_plat_dev_addr(dev); 744 744 return 0;
+4 -8
drivers/net/ethernet/xircom/xirc2ps_cs.c
··· 671 671 void *priv) 672 672 { 673 673 struct net_device *dev = priv; 674 - int i; 675 674 676 675 if (tuple->TupleDataLen != 13) 677 676 return -EINVAL; ··· 678 679 (tuple->TupleData[2] != 6)) 679 680 return -EINVAL; 680 681 /* another try (James Lehmer's CE2 version 4.1)*/ 681 - for (i = 2; i < 6; i++) 682 - dev->dev_addr[i] = tuple->TupleData[i+2]; 682 + dev_addr_mod(dev, 2, &tuple->TupleData[2], 4); 683 683 return 0; 684 684 }; 685 685 ··· 740 742 len = pcmcia_get_tuple(link, 0x89, &buf); 741 743 /* data layout looks like tuple 0x22 */ 742 744 if (buf && len == 8) { 743 - if (*buf == CISTPL_FUNCE_LAN_NODE_ID) { 744 - int i; 745 - for (i = 2; i < 6; i++) 746 - dev->dev_addr[i] = buf[i+2]; 747 - } else 745 + if (*buf == CISTPL_FUNCE_LAN_NODE_ID) 746 + dev_addr_mod(dev, 2, &buf[2], 4); 747 + else 748 748 err = -1; 749 749 } 750 750 kfree(buf);