From: Lev Iserovich <Lev.Iserovich@deshawresearch.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] fdt: fix setting MAC addresses for multiple interfaces
Date: Thu, 7 Jan 2016 18:04:16 -0500 [thread overview]
Message-ID: <568EEEF0.8060903@deshawresearch.com> (raw)
In-Reply-To: <1452114118-11100-1-git-send-email-iserovil@deshawresearch.com>
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>
---
Changes in v2:
- Rebase on u-boot-net patches:
http://patchwork.ozlabs.org/patch/539373/
http://patchwork.ozlabs.org/patch/539374/
- Recompute offset based on property index
---
common/fdt_support.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 48faba9..713d2a4 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -481,23 +481,30 @@ 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);
next prev parent reply other threads:[~2016-01-07 23:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Lev Iserovich [this message]
2016-04-26 19:27 ` [U-Boot] [PATCH v2] " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=568EEEF0.8060903@deshawresearch.com \
--to=lev.iserovich@deshawresearch.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox