Skip to content

Commit

Permalink
gianfar: Use random MAC address when none is given
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fidomax authored and davem330 committed Jul 14, 2020
1 parent 3195c47 commit ff021f2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/net/ethernet/freescale/gianfar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit ff021f2

Please sign in to comment.