[U-Boot] [PATCH v3] davinci: cleanup davinci_sync_env_enetaddr() fucntion
Holger Freyther
holger at freyther.de
Mon Jan 14 16:16:29 CET 2013
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.
More information about the U-Boot
mailing list