diff options
author | David S. Miller <davem@davemloft.net> | 2018-12-03 15:40:30 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-12-03 15:40:30 -0800 |
commit | 37a0bc39d726a15073cca64887f01e3a12b24a18 (patch) | |
tree | 83b758a883bbc0a8866e1647c7a27c676c54d64a /drivers/net | |
parent | 82208d0d54ab85d8fedbb1c9a1960bd401a4ca1a (diff) | |
parent | 18dbfc81de708409ed82e95b418ef7092e91c2fb (diff) | |
download | linux-37a0bc39d726a15073cca64887f01e3a12b24a18.tar.bz2 |
Merge branch 'davinci_emac-read-the-MAC-address-from-nvmem'
Bartosz Golaszewski says:
====================
davinci_emac: read the MAC address from nvmem
This series is part of a bigger series that aims at removing the platform
data structure from the at24 EEPROM driver[1].
We provide a generalized version of of_get_nvmem_mac_address(), switch the
only user of the of_ variant to using it, remove the previous
implementation and use the new routine in the davinci_emac driver.
[1] https://lkml.org/lkml/2018/11/13/884
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/cadence/macb_main.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/davinci_emac.c | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 1d86b4d5645a..d9a208f7bb40 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -4055,7 +4055,7 @@ static int macb_probe(struct platform_device *pdev) if (mac) { ether_addr_copy(bp->dev->dev_addr, mac); } else { - err = of_get_nvmem_mac_address(np, bp->dev->dev_addr); + err = nvmem_get_mac_address(&pdev->dev, bp->dev->dev_addr); if (err) { if (err == -EPROBE_DEFER) goto err_out_free_netdev; diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 9153db120352..840820402cd0 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1912,11 +1912,15 @@ 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 */ - 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); + /* 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; |