davinci: cleanup davinci_sync_env_enetaddr() fucntion
PATCH v3 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.
---
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(-)
arch/arm/cpu/arm926ejs/davinci/misc.c +6 -3
@@ -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 */
Signature · 1 line
1.6.2.4
PATCH v3 1/1 davinci: cleanup davinci_sync_env_enetaddr() fucntion
-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>
PATCH v3 1/1 davinci: cleanup davinci_sync_env_enetaddr() fucntion
In reply to Manjunath HadliQuoted 4 lines · Manjunath Hadli <manjunath.hadli <at> ti.com> writes:
check for the return status for
eth_getenv_enetaddr_by_index()andeth_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.
arch/arm/cpu/arm926ejs/davinci/misc.c void davinci_emac_mii_mode_sel(int mode_sel) · line 107
Quoted 3 lines
arch/arm/cpu/arm926ejs/davinci/misc.c +2
-1-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.
arch/arm/cpu/arm926ejs/davinci/misc.c void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr) · line 118
Quoted 5 lines
arch/arm/cpu/arm926ejs/davinci/misc.c +3
-1-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.