Skip to content

Commit ff021f2

Browse files
fidomaxdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3195c47 commit ff021f2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
779779

780780
mac_addr = of_get_mac_address(np);
781781

782-
if (!IS_ERR(mac_addr))
782+
if (!IS_ERR(mac_addr)) {
783783
ether_addr_copy(dev->dev_addr, mac_addr);
784+
} else {
785+
eth_hw_addr_random(dev);
786+
dev_info(&ofdev->dev, "Using random MAC address: %pM\n", dev->dev_addr);
787+
}
784788

785789
if (model && !strcasecmp(model, "TSEC"))
786790
priv->device_flags |= FSL_GIANFAR_DEV_HAS_GIGABIT |

0 commit comments

Comments
 (0)