From 6937664426446b76308e7125e9f357e0f12c731a Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Wed, 18 Jan 2012 22:56:33 +0000 Subject: [PATCH] net/eth.c: fix eth_write_hwaddr() to use dev->enetaddr as fall back Ignore the return value of eth_getenv_enetaddr_by_index(), and if it fails, fall back to use dev->enetaddr, which could be filled up by the ethernet device driver: With the current code, introduced with below commit, eth_write_hwaddr() will fail immediately if there is no ethaddr in the environment variables. However, e.g. for an overo based product that uses the SMSC911x ethernet chip (with the MAC address set via EEPROM connected to the SMSC911x chip), the MAC address is still OK. On mx28 boards that are depending on the OCOTP bits to set the MAC address (like the Denx m28 board), the OCOTP bits should be used instead of failing on the environment variables. Actually, this was the original behavior, and was later changed by commit 7616e7850804c7c69e0a22c179dfcba9e8f3f587. Signed-off-by: Eric Miao Acked-by: Simon Glass Acked-by: Dirk Behme CC: Stefan Roese CC: Eric Miao CC: Wolfgang Denk CC: Philip Balister CC: Zach Sadecki --- net/eth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/eth.c b/net/eth.c index aabb343..3eeb908 100644 --- a/net/eth.c +++ b/net/eth.c @@ -172,8 +172,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, unsigned char env_enetaddr[6]; int ret = 0; - if (!eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr)) - return -1; + eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr); if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) { if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&