Commit 4abd7cff authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller
Browse files

ethernet: use eth_hw_addr_set() in unmaintained drivers



Commit 406f42fa ("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: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0e9e7598
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1693,6 +1693,7 @@ static int xgmac_probe(struct platform_device *pdev)
	struct resource *res;
	struct net_device *ndev = NULL;
	struct xgmac_priv *priv = NULL;
	u8 addr[ETH_ALEN];
	u32 uid;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1785,7 +1786,8 @@ static int xgmac_probe(struct platform_device *pdev)
	ndev->max_mtu = XGMAC_MAX_MTU;

	/* Get the MAC address */
	xgmac_get_mac_addr(priv->base, ndev->dev_addr, 0);
	xgmac_get_mac_addr(priv->base, addr, 0);
	eth_hw_addr_set(ndev, addr);
	if (!is_valid_ether_addr(ndev->dev_addr))
		netdev_warn(ndev, "MAC address %pM not valid",
			 ndev->dev_addr);
+7 −4
Original line number Diff line number Diff line
@@ -1314,6 +1314,7 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
	int tmp;
	unsigned rev_type = 0;
	int eeprom_buff[CHKSUM_LEN];
	u8 addr[ETH_ALEN];
	int retval;

	/* Initialize the device structure. */
@@ -1387,9 +1388,10 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
		for (i = 0; i < ETH_ALEN / 2; i++) {
			unsigned int Addr;
			Addr = readreg(dev, PP_IA + i * 2);
			dev->dev_addr[i * 2] = Addr & 0xFF;
			dev->dev_addr[i * 2 + 1] = Addr >> 8;
			addr[i * 2] = Addr & 0xFF;
			addr[i * 2 + 1] = Addr >> 8;
		}
		eth_hw_addr_set(dev, addr);

		/* Load the Adapter Configuration.
		 * Note:  Barring any more specific information from some
@@ -1464,9 +1466,10 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular)
		/* eeprom_buff has 32-bit ints, so we can't just memcpy it */
		/* store the initial memory base address */
		for (i = 0; i < ETH_ALEN / 2; i++) {
			dev->dev_addr[i * 2] = eeprom_buff[i];
			dev->dev_addr[i * 2 + 1] = eeprom_buff[i] >> 8;
			addr[i * 2] = eeprom_buff[i];
			addr[i * 2 + 1] = eeprom_buff[i] >> 8;
		}
		eth_hw_addr_set(dev, addr);
		cs89_dbg(1, debug, "%s: new adapter_cnf: 0x%x\n",
			 dev->name, lp->adapter_cnf);
	}
+5 −2
Original line number Diff line number Diff line
@@ -1425,6 +1425,7 @@ dm9000_probe(struct platform_device *pdev)
	enum of_gpio_flags flags;
	struct regulator *power;
	bool inv_mac_addr = false;
	u8 addr[ETH_ALEN];

	power = devm_regulator_get(dev, "vcc");
	if (IS_ERR(power)) {
@@ -1666,7 +1667,8 @@ dm9000_probe(struct platform_device *pdev)

	/* try reading the node address from the attached EEPROM */
	for (i = 0; i < 6; i += 2)
		dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
		dm9000_read_eeprom(db, i / 2, addr + i);
	eth_hw_addr_set(ndev, addr);

	if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
		mac_src = "platform data";
@@ -1678,7 +1680,8 @@ dm9000_probe(struct platform_device *pdev)

		mac_src = "chip";
		for (i = 0; i < 6; i++)
			ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
			addr[i] = ior(db, i + DM9000_PAR);
		eth_hw_addr_set(ndev, pdata->dev_addr);
	}

	if (!is_valid_ether_addr(ndev->dev_addr)) {
+6 −2
Original line number Diff line number Diff line
@@ -1154,8 +1154,12 @@ static int ethoc_probe(struct platform_device *pdev)
	/* Check that the given MAC address is valid. If it isn't, read the
	 * current MAC from the controller.
	 */
	if (!is_valid_ether_addr(netdev->dev_addr))
		ethoc_get_mac_address(netdev, netdev->dev_addr);
	if (!is_valid_ether_addr(netdev->dev_addr)) {
		u8 addr[ETH_ALEN];

		ethoc_get_mac_address(netdev, addr);
		eth_hw_addr_set(netdev, addr);
	}

	/* Check the MAC again for validity, if it still isn't choose and
	 * program a random one.
+3 −1
Original line number Diff line number Diff line
@@ -482,6 +482,7 @@ static int fealnx_init_one(struct pci_dev *pdev,
	struct net_device *dev;
	void *ring_space;
	dma_addr_t ring_dma;
	u8 addr[ETH_ALEN];
#ifdef USE_IO_OPS
	int bar = 0;
#else
@@ -525,7 +526,8 @@ static int fealnx_init_one(struct pci_dev *pdev,

	/* read ethernet id */
	for (i = 0; i < 6; ++i)
		dev->dev_addr[i] = ioread8(ioaddr + PAR0 + i);
		addr[i] = ioread8(ioaddr + PAR0 + i);
	eth_hw_addr_set(dev, addr);

	/* Reset the chip to erase previous misconfiguration. */
	iowrite32(0x00000001, ioaddr + BCR);
Loading