Skip to contentSkip to conversation

davinci: cleanup davinci_sync_env_enetaddr() fucntion

PATCH Superseded Manjunath Hadli 2 participants 2 messages Feb 6, 2012 Arm (32-bit)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 davinci: cleanup davinci_sync_env_enetaddr() fucntion

check for the return status for eth_getenv_enetaddr_by_index() and eth_setenv_enetaddr() functions and print appropriate message on failure. Also convert debug message to printf().

---
 arch/arm/cpu/arm926ejs/davinci/misc.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
arch/arm/cpu/arm926ejs/davinci/misc.c +8 -4
index 5f510b6..3036e8a 100644
@@ -101,18 +101,22 @@ 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 && !memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
 		/*
 		 * There is no MAC address in the environment, so we
 		 * initialize it from the value in the EEPROM.
 		 */
-		debug("### Setting environment from EEPROM MAC address = "
+		printf("### 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 */
 
Signature · 1 line
1.6.2.4
#1 lore raw

PATCH 1/1 davinci: cleanup davinci_sync_env_enetaddr() fucntion

arch/arm/cpu/arm926ejs/davinci/misc.c void davinci_emac_mii_mode_sel(int mode_sel) · line 107

Quoted 5 lines · On Monday 06 February 2012 04:59:53 Manjunath Hadli wrote:
arch/arm/cpu/arm926ejs/davinci/misc.c +2 -0
 
+	ret = eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr);
+	if (ret && !memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {

i don't think the memcmp() is necessary. the core code already calls is_valid_ether_addr() and one of the checks in there is for all zeros. -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/20120206/5685e7d0/attachment.pgp>