Skip to content

Commit

Permalink
net: bcmgenet: Generate a random MAC if none is valid
Browse files Browse the repository at this point in the history
Instead of having a hard failure and stopping the driver's probe
routine, generate a random Ethernet MAC address to keep going.

Signed-off-by: Florian Fainelli <[email protected]>
Acked-by: Doug Berger <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ffainelli authored and davem330 committed Oct 16, 2019
1 parent e9c43ad commit d033716
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions drivers/net/ethernet/broadcom/genet/bcmgenet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3461,16 +3461,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
goto err;
}

if (dn) {
if (dn)
macaddr = of_get_mac_address(dn);
if (IS_ERR(macaddr)) {
dev_err(&pdev->dev, "can't find MAC address\n");
err = -EINVAL;
goto err;
}
} else {
else
macaddr = pd->mac_address;
}

priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base)) {
Expand All @@ -3482,7 +3476,12 @@ static int bcmgenet_probe(struct platform_device *pdev)

SET_NETDEV_DEV(dev, &pdev->dev);
dev_set_drvdata(&pdev->dev, dev);
ether_addr_copy(dev->dev_addr, macaddr);
if (IS_ERR_OR_NULL(macaddr) || !is_valid_ether_addr(macaddr)) {
dev_warn(&pdev->dev, "using random Ethernet MAC\n");
eth_hw_addr_random(dev);
} else {
ether_addr_copy(dev->dev_addr, macaddr);
}
dev->watchdog_timeo = 2 * HZ;
dev->ethtool_ops = &bcmgenet_ethtool_ops;
dev->netdev_ops = &bcmgenet_netdev_ops;
Expand Down

0 comments on commit d033716

Please sign in to comment.