[U-Boot] rpi: set ethaddr as well

Stephen Warren swarren at wwwdotorg.org
Sat Feb 6 05:06:54 CET 2016


On 02/03/2016 08:08 AM, Lubomir Rintel wrote:
> Let's set "ethaddr" when we get the ethernet address too, so that
> fdt_fixup_ethernet() sets the address in the device tree and the Linux
> driver can pick it up.

You need to Cc the maintainer who will apply this (Tom Rini).

This seems OK, but ...

> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> index b344362..d7ad79d 100644
> --- a/board/raspberrypi/rpi/rpi.c
> +++ b/board/raspberrypi/rpi/rpi.c
> @@ -254,6 +254,9 @@ static void set_usbethaddr(void)
>  
>  	eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
>  
> +	if (!getenv("ethaddr"))
> +		setenv("ethaddr", getenv("usbethaddr"));

Rather than setting duplicate environment variables, wouldn't it be
better to modify the code that copies ethaddr into the DT so that it
used the correct environment variable for the platform? Perhaps that's
not worth it though.

Why use setenv() directly rather than just calling eth_setenv_enetaddr()
in both places? In the current code, I wonder what happens if
eth_setenv_enetaddr() fails, so presumably getenv() returns NULL or
whatever random value usbethaddr had since it wasn't over-written?

Tested-by: Stephen Warren <swarren at wwwdotorg.org>


More information about the U-Boot mailing list