Skip to content

Commit 18dbfc8

Browse files
brgldavem330
authored andcommitted
net: davinci_emac: use nvmem_get_mac_address()
All DaVinci boards still supported in board files now define nvmem cells containing the MAC address. We want to stop using the setup callback from at24 so the MAC address for those users will no longer be provided over platform data. If we didn't get a valid MAC in pdata, try nvmem before resorting to a random MAC. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent afa64a7 commit 18dbfc8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/net/ethernet/ti/davinci_emac.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,11 +1912,15 @@ static int davinci_emac_probe(struct platform_device *pdev)
19121912
ether_addr_copy(ndev->dev_addr, priv->mac_addr);
19131913

19141914
if (!is_valid_ether_addr(priv->mac_addr)) {
1915-
/* Use random MAC if none passed */
1916-
eth_hw_addr_random(ndev);
1917-
memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
1918-
dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
1919-
priv->mac_addr);
1915+
/* Try nvmem if MAC wasn't passed over pdata or DT. */
1916+
rc = nvmem_get_mac_address(&pdev->dev, priv->mac_addr);
1917+
if (rc) {
1918+
/* Use random MAC if still none obtained. */
1919+
eth_hw_addr_random(ndev);
1920+
memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
1921+
dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
1922+
priv->mac_addr);
1923+
}
19201924
}
19211925

19221926
ndev->netdev_ops = &emac_netdev_ops;

0 commit comments

Comments
 (0)