ethernet: manually convert memcpy(dev_addr,..., sizeof(addr))
authorJakub Kicinski <kuba@kernel.org>
Wed, 13 Oct 2021 20:44:32 +0000 (13:44 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 Oct 2021 16:22:19 +0000 (09:22 -0700)
A handful of drivers use sizeof(addr) for the size of
the address, after manually confirming the size is
indeed 6 convert them to eth_hw_addr_set().

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Petko Manolov <petkan@nucleusys.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cadence/macb_main.c
drivers/net/ethernet/dnet.c
drivers/net/ethernet/pasemi/pasemi_mac.c
drivers/net/ethernet/ti/cpmac.c
drivers/net/usb/pegasus.c

index 683f14665c2c0c4fbb3dd0911a8de1f911cbd2d7..029dea2873e3e55da302ea51b23ed09c2afa9454 100644 (file)
@@ -313,7 +313,7 @@ static void macb_get_hwaddr(struct macb *bp)
                addr[5] = (top >> 8) & 0xff;
 
                if (is_valid_ether_addr(addr)) {
-                       memcpy(bp->dev->dev_addr, addr, sizeof(addr));
+                       eth_hw_addr_set(bp->dev, addr);
                        return;
                }
        }
index 3ed21ba4eb9972c989ec7b1f9f912298de801f49..92462ed87bc4382a27f6a12c974dbdbeea7b3713 100644 (file)
@@ -93,7 +93,7 @@ static void dnet_get_hwaddr(struct dnet *bp)
        *((__be16 *)(addr + 4)) = cpu_to_be16(tmp);
 
        if (is_valid_ether_addr(addr))
-               memcpy(bp->dev->dev_addr, addr, sizeof(addr));
+               eth_hw_addr_set(bp->dev, addr);
 }
 
 static int dnet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
index 5512e43bafc1fe2a276be2ee6d536674b498a27c..f0ace3a0e85cb70b42554498283cfaf58c3b05a1 100644 (file)
@@ -1722,7 +1722,7 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                err = -ENODEV;
                goto out;
        }
-       memcpy(dev->dev_addr, mac->mac_addr, sizeof(mac->mac_addr));
+       eth_hw_addr_set(dev, mac->mac_addr);
 
        ret = mac_to_intf(mac);
        if (ret < 0) {
index 02d4e51f73064e70a2d59d39f2edc1f5b593e4ea..7449436fc87ca5db772c92e752680b3a73589b6c 100644 (file)
@@ -1112,7 +1112,7 @@ static int cpmac_probe(struct platform_device *pdev)
        priv->dev = dev;
        priv->ring_size = 64;
        priv->msg_enable = netif_msg_init(debug_level, 0xff);
-       memcpy(dev->dev_addr, pdata->dev_addr, sizeof(pdata->dev_addr));
+       eth_hw_addr_set(dev, pdata->dev_addr);
 
        snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT,
                                                mdio_bus_id, phy_id);
index 6a92a3fef75e5fece599307bf2aec08825010876..c4cd40b090fd05c2ca4bb4423f914459bf095996 100644 (file)
@@ -357,7 +357,7 @@ static void set_ethernet_addr(pegasus_t *pegasus)
                        goto err;
        }
 
-       memcpy(pegasus->net->dev_addr, node_id, sizeof(node_id));
+       eth_hw_addr_set(pegasus->net, node_id);
 
        return;
 err: