diff options
author | Maxim Kochetkov <fido_max@inbox.ru> | 2020-07-14 15:01:04 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-07-14 14:16:37 -0700 |
commit | ff021f22ea8f1388ced048243c6e06ca5cfbd62a (patch) | |
tree | c1f95dd85cc5574ecad8826b6b4ec0c89a3b3608 /drivers/net/ethernet/freescale/gianfar.c | |
parent | 3195c4706b00106aa82c73acd28340fa8fc2bfc1 (diff) |
gianfar: Use random MAC address when none is given
If there is no valid MAC address in the device tree,
use a random MAC address.
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/freescale/gianfar.c')
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index b3c69e9038ea..b513b8c5c3b5 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -779,8 +779,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) mac_addr = of_get_mac_address(np); - if (!IS_ERR(mac_addr)) + if (!IS_ERR(mac_addr)) { ether_addr_copy(dev->dev_addr, mac_addr); + } else { + eth_hw_addr_random(dev); + dev_info(&ofdev->dev, "Using random MAC address: %pM\n", dev->dev_addr); + } if (model && !strcasecmp(model, "TSEC")) priv->device_flags |= FSL_GIANFAR_DEV_HAS_GIGABIT | |