Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18dbfc81 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by David S. Miller
Browse files

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: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent afa64a72
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -1912,12 +1912,16 @@ static int davinci_emac_probe(struct platform_device *pdev)
		ether_addr_copy(ndev->dev_addr, priv->mac_addr);

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

	ndev->netdev_ops = &emac_netdev_ops;
	ndev->ethtool_ops = &ethtool_ops;