All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3] davinci: cleanup davinci_sync_env_enetaddr() fucntion
@ 2012-02-10  5:52 Manjunath Hadli
  2012-02-10 16:58 ` Mike Frysinger
  2013-01-14 15:16 ` Holger Freyther
  0 siblings, 2 replies; 3+ messages in thread
From: Manjunath Hadli @ 2012-02-10  5:52 UTC (permalink / raw)
  To: u-boot

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.hadli@ti.com>
Cc: Tom Rini <trini@ti.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Wolfgang Denk <wd@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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v3] davinci: cleanup davinci_sync_env_enetaddr() fucntion
  2012-02-10  5:52 [U-Boot] [PATCH v3] davinci: cleanup davinci_sync_env_enetaddr() fucntion Manjunath Hadli
@ 2012-02-10 16:58 ` Mike Frysinger
  2013-01-14 15:16 ` Holger Freyther
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2012-02-10 16:58 UTC (permalink / raw)
  To: u-boot

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120210/7b1e2a03/attachment.pgp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v3] davinci: cleanup davinci_sync_env_enetaddr() fucntion
  2012-02-10  5:52 [U-Boot] [PATCH v3] davinci: cleanup davinci_sync_env_enetaddr() fucntion Manjunath Hadli
  2012-02-10 16:58 ` Mike Frysinger
@ 2013-01-14 15:16 ` Holger Freyther
  1 sibling, 0 replies; 3+ messages in thread
From: Holger Freyther @ 2013-01-14 15:16 UTC (permalink / raw)
  To: u-boot

Manjunath Hadli <manjunath.hadli <at> ti.com> writes:

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

I am upgrading from v2011.12 (as I have some ubifsmount issues and
don't want to debug this on an old ubi) and I saw that setting the
MAC address from EEPROM is broken.


> -	if (!memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
> +	ret = eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr);
> +	if (ret) {

In case there is no mac address in the environment the net/eth.c code
will set env_enetaddr to all 0. This means that is_valid_ether_addr 
inside eth_getenv_enetaddr will return 0 (as of not valid). That
also means that the below function will not be called.

I assume the right fix is to change the condition to !ret.


> -		eth_setenv_enetaddr("ethaddr", rom_enetaddr);
> +		ret = !eth_setenv_enetaddr("ethaddr", rom_enetaddr);
>  	}
> +	if (!ret)
> +		printf("Failed to set mac address from EEPROM\n");

adding %d for 'ret' would be nice.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-14 15:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-10  5:52 [U-Boot] [PATCH v3] davinci: cleanup davinci_sync_env_enetaddr() fucntion Manjunath Hadli
2012-02-10 16:58 ` Mike Frysinger
2013-01-14 15:16 ` Holger Freyther

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.