summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorLev Iserovich <Lev.Iserovich@deshawresearch.com>2016-01-07 18:04:16 -0500
committerJoe Hershberger <joe.hershberger@ni.com>2016-05-03 17:52:10 -0500
commita434fd1d282fd32d81296c6d4c2e0911f6e488b3 (patch)
treef0084393ec6358e49e2e18b6f11e01d5900e470a /common
parente96e064f51139c4af39f14499564ef76e40bbc29 (diff)
downloadu-boot-a434fd1d282fd32d81296c6d4c2e0911f6e488b3.tar.gz
u-boot-a434fd1d282fd32d81296c6d4c2e0911f6e488b3.tar.bz2
u-boot-a434fd1d282fd32d81296c6d4c2e0911f6e488b3.zip
fdt: fix setting MAC addresses for multiple interfaces
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. Signed-off-by: Lev Iserovich <iserovil@deshawresearch.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'common')
-rw-r--r--common/fdt_support.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index ced119e70d..42e5d8a1d2 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -467,23 +467,31 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
void fdt_fixup_ethernet(void *fdt)
{
- int node, i, j;
+ int i, j, prop;
char *tmp, *end;
char mac[16];
const char *path;
unsigned char mac_addr[6];
int offset;
- node = fdt_path_offset(fdt, "/aliases");
- if (node < 0)
+ if (fdt_path_offset(fdt, "/aliases") < 0)
return;
- for (offset = fdt_first_property_offset(fdt, node);
- offset > 0;
- offset = fdt_next_property_offset(fdt, offset)) {
+ /* Cycle through all aliases */
+ for (prop = 0; ; prop++) {
const char *name;
int len = strlen("ethernet");
+ /* FDT might have been edited, recompute the offset */
+ offset = fdt_first_property_offset(fdt,
+ fdt_path_offset(fdt, "/aliases"));
+ /* Select property number 'prop' */
+ for (i = 0; i < prop; i++)
+ offset = fdt_next_property_offset(fdt, offset);
+
+ if (offset < 0)
+ break;
+
path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
if (!strncmp(name, "ethernet", len)) {
i = trailing_strtol(name);