check for the return status for eth_getenv_enetaddr_by_index()
and eth_setenv_enetaddr() functions and print appropriate message
on failure.

Signed-off-by: Manjunath Hadli <manjunath.ha...@ti.com>
Cc: Tom Rini <tr...@ti.com>
Cc: Mike Frysinger <vap...@gentoo.org>
Cc: Wolfgang Denk <w...@denx.de>
---
 Changes for v3:
 undo conversion of debug statement to printf().

 Changes for v2:
 Removed additional check of comparing ethernet address is all
 zeros, As the core code already calls is_valid_ether_addr()
 and one of the checks in there is for all zeros.

 arch/arm/cpu/arm926ejs/davinci/misc.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/davinci/misc.c 
b/arch/arm/cpu/arm926ejs/davinci/misc.c
index 5f510b6..c310c69 100644
--- a/arch/arm/cpu/arm926ejs/davinci/misc.c
+++ b/arch/arm/cpu/arm926ejs/davinci/misc.c
@@ -101,9 +101,10 @@ void davinci_emac_mii_mode_sel(int mode_sel)
 void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr)
 {
        uint8_t env_enetaddr[6];
+       int ret;
 
-       eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr);
-       if (!memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
+       ret = eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr);
+       if (ret) {
                /*
                 * There is no MAC address in the environment, so we
                 * initialize it from the value in the EEPROM.
@@ -111,8 +112,10 @@ void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr)
                debug("### Setting environment from EEPROM MAC address = "
                        "\"%pM\"\n",
                        env_enetaddr);
-               eth_setenv_enetaddr("ethaddr", rom_enetaddr);
+               ret = !eth_setenv_enetaddr("ethaddr", rom_enetaddr);
        }
+       if (!ret)
+               printf("Failed to set mac address from EEPROM\n");
 }
 #endif /* CONFIG_DRIVER_TI_EMAC */
 
-- 
1.6.2.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to