diff options
author | Lucas Stach <l.stach@pengutronix.de> | 2013-06-03 04:38:39 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-05 04:00:32 +0400 |
commit | ff5b2fabf53426c15a5f041505687f94d1b2109f (patch) | |
tree | 77b814a4b50598ce19b1af1e4e4e70313864024a /drivers | |
parent | e768fb292d362ff2742d843e346a10853bde68be (diff) | |
download | linux-ff5b2fabf53426c15a5f041505687f94d1b2109f.tar.xz |
net: fec: add fallback to random MAC address
If no valid MAC address could be obtained from the hardware,
fall back to a randomly generated one.
Signed-off-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/freescale/fec_main.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 85a06037b242..a667015be22a 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1038,6 +1038,18 @@ static void fec_get_mac(struct net_device *ndev) iap = &tmpaddr[0]; } + /* + * 5) random mac address + */ + if (!is_valid_ether_addr(iap)) { + /* Report it and use a random ethernet address instead */ + netdev_err(ndev, "Invalid MAC address: %pM\n", iap); + eth_hw_addr_random(ndev); + netdev_info(ndev, "Using random MAC address: %pM\n", + ndev->dev_addr); + return; + } + memcpy(ndev->dev_addr, iap, ETH_ALEN); /* Adjust MAC if using macaddr */ |