diff mbox

[U-Boot] rpi: set ethaddr as well

Message ID 1454512089-26346-1-git-send-email-lkundrak@v3.sk
State Accepted
Commit 859f1437156b60dc0655917d067fec566885ac96
Delegated to: Tom Rini
Headers show

Commit Message

Lubomir Rintel Feb. 3, 2016, 3:08 p.m. UTC
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.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
The related Linux kernel change submitted here:
http://lists.infradead.org/pipermail/linux-rpi-kernel/2016-February/003207.html

 board/raspberrypi/rpi/rpi.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stephen Warren Feb. 6, 2016, 4:06 a.m. UTC | #1
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@wwwdotorg.org>
Tom Rini Feb. 8, 2016, 8:49 p.m. UTC | #2
On Wed, Feb 03, 2016 at 04:08:09PM +0100, 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.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> Tested-by: Stephen Warren <swarren@wwwdotorg.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

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"));
+
 	return;
 }