ethernet: amd: use eth_hw_addr_set()
authorJakub Kicinski <kuba@kernel.org>
Fri, 15 Oct 2021 22:16:44 +0000 (15:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 16 Oct 2021 07:53:46 +0000 (08:53 +0100)
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.

Read the address into an array on the stack, then call
eth_hw_addr_set().

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amd/amd8111e.c
drivers/net/ethernet/amd/pcnet32.c

index 0b493467b04218ade626241012d27107573994b6..9421afb950f791c921306a45f03a3ad31e4a554d 100644 (file)
@@ -1743,6 +1743,7 @@ static int amd8111e_probe_one(struct pci_dev *pdev,
        unsigned long reg_addr, reg_len;
        struct amd8111e_priv *lp;
        struct net_device *dev;
+       u8 addr[ETH_ALEN];
 
        err = pci_enable_device(pdev);
        if (err) {
@@ -1809,7 +1810,8 @@ static int amd8111e_probe_one(struct pci_dev *pdev,
 
        /* Initializing MAC address */
        for (i = 0; i < ETH_ALEN; i++)
-               dev->dev_addr[i] = readb(lp->mmio + PADR + i);
+               addr[i] = readb(lp->mmio + PADR + i);
+       eth_hw_addr_set(dev, addr);
 
        /* Setting user defined parametrs */
        lp->ext_phy_option = speed_duplex[card_idx];
index 820baa2604acc5fa9eb855254bb74b4825ca4052..f5c50ff377ff70b44c4cc5a475c13ea2b7a3cea0 100644 (file)
@@ -1595,6 +1595,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
        struct net_device *dev;
        const struct pcnet32_access *a = NULL;
        u8 promaddr[ETH_ALEN];
+       u8 addr[ETH_ALEN];
        int ret = -ENODEV;
 
        /* reset the chip */
@@ -1760,9 +1761,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
                unsigned int val;
                val = a->read_csr(ioaddr, i + 12) & 0x0ffff;
                /* There may be endianness issues here. */
-               dev->dev_addr[2 * i] = val & 0x0ff;
-               dev->dev_addr[2 * i + 1] = (val >> 8) & 0x0ff;
+               addr[2 * i] = val & 0x0ff;
+               addr[2 * i + 1] = (val >> 8) & 0x0ff;
        }
+       eth_hw_addr_set(dev, addr);
 
        /* read PROM address and compare with CSR address */
        for (i = 0; i < ETH_ALEN; i++)
@@ -1780,8 +1782,11 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
        }
 
        /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */
-       if (!is_valid_ether_addr(dev->dev_addr))
-               eth_zero_addr(dev->dev_addr);
+       if (!is_valid_ether_addr(dev->dev_addr)) {
+               static const u8 zero_addr[ETH_ALEN] = {};
+
+               eth_hw_addr_set(dev, zero_addr);
+       }
 
        if (pcnet32_debug & NETIF_MSG_PROBE) {
                pr_cont(" %pM", dev->dev_addr);