public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces
@ 2016-01-06 21:01 Lev Iserovich
  2016-01-07  2:42 ` Bin Meng
  2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
  0 siblings, 2 replies; 12+ messages in thread
From: Lev Iserovich @ 2016-01-06 21:01 UTC (permalink / raw)
  To: u-boot

For multiple ethernet interfaces the FDT offset of '/aliases' will change as we
are adding MAC addresses to the FDT.
Therefore only the first interface ('ethernet0') will get properly updated in
the FDT, with the rest getting FDT errors when we try to set their MAC address.

Switch to using fdt_get_alias() which is the proper way to get the FDT path.

Signed-off-by: Lev Iserovich <iserovil@deshawresearch.com>
---

 common/fdt_support.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 66464db..20e0e1c 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -481,16 +481,12 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
 
 void fdt_fixup_ethernet(void *fdt)
 {
-	int node, i, j;
+	int i, j;
 	char enet[16], *tmp, *end;
 	char mac[16];
 	const char *path;
 	unsigned char mac_addr[6];
 
-	node = fdt_path_offset(fdt, "/aliases");
-	if (node < 0)
-		return;
-
 	if (!getenv("ethaddr")) {
 		if (getenv("usbethaddr")) {
 			strcpy(mac, "usbethaddr");
@@ -505,7 +501,7 @@ void fdt_fixup_ethernet(void *fdt)
 	i = 0;
 	while ((tmp = getenv(mac)) != NULL) {
 		sprintf(enet, "ethernet%d", i);
-		path = fdt_getprop(fdt, node, enet, NULL);
+		path = fdt_get_alias(fdt, enet);
 		if (!path) {
 			debug("No alias for %s\n", enet);
 			sprintf(mac, "eth%daddr", ++i);
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-05-04 14:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-06 21:01 [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces Lev Iserovich
2016-01-07  2:42 ` Bin Meng
2016-01-07 20:21   ` Lev Iserovich
2016-01-07 23:04 ` [U-Boot] [PATCH v2] " Lev Iserovich
2016-04-26 19:27   ` Joe Hershberger
2016-04-27  0:06   ` Bin Meng
2016-04-27  1:57     ` Bin Meng
2016-05-02 17:12       ` Joe Hershberger
2016-05-02 16:01     ` Lev Iserovich
2016-05-03 19:52       ` Joe Hershberger
2016-05-04 14:44         ` Lev Iserovich
2016-05-03 20:16   ` [U-Boot] " Joe Hershberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox