From: Tuomas Tynkkynen <tuomas@tuxera.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fdt_support: Fixup 'ethernet' aliases not ending in digits
Date: Sat, 18 Mar 2017 20:20:07 +0200 [thread overview]
Message-ID: <20170318202007.3c053d78@duuni> (raw)
In-Reply-To: <20170318012651.GB19897@bill-the-cat>
On Fri, 17 Mar 2017 21:26:51 -0400
Tom Rini <trini@konsulko.com> wrote:
> On Fri, Mar 17, 2017 at 09:44:59PM +0200, Tuomas Tynkkynen wrote:
>
> > The Raspberry Pi device tree files since Linux v4.9 have a "ethernet"
> > alias pointing to the on-board Ethernet device node. However,
> > U-Boot's fdt_fixup_ethernet() (and the kernel's of_alias_scan()) only
> > looks at ethernet aliases ending in digits. Make it also check the
> > "ethernet" alias.
> >
> > Without this Linux isn't told of the MAC address provided by the
> > RPI firmware and the ethernet device is always assigned a random MAC
> > address.
> >
> > The device trees themselves can't be fixed as someone is already
> > depending on the "ethernet" alias:
> > https://github.com/raspberrypi/firmware/issues/613
> >
> > Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>
>
> I looked into this a bit and there's a few other (much older) examples
> of 'ethernet' rather than 'ethernet0' and the spec doesn't mandate
> aliases end in a number.
Ah, good to know.
> That said, looking at the code, I think we can do this in a more clear
> manner. Can you test this please?
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 55d4d6f6d444..80186a95baf0 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -482,7 +482,6 @@ void fdt_fixup_ethernet(void *fdt)
> /* 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,
> @@ -495,16 +494,13 @@ void fdt_fixup_ethernet(void *fdt)
> break;
>
> path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
> - if (!strncmp(name, "ethernet", len)) {
> + if (!strncmp(name, "ethernet", 8)) {
> i = trailing_strtol(name);
> - if (i != -1) {
> - if (i == 0)
> - strcpy(mac, "ethaddr");
> - else
> - sprintf(mac, "eth%daddr", i);
> - } else {
> - continue;
> - }
> + /* Handle 'ethernet0' (0) and 'ethernet' (-1) */
> + if (i <= 0)
> + strcpy(mac, "ethaddr");
> + else
> + sprintf(mac, "eth%daddr", i);
> tmp = getenv(mac);
> if (!tmp)
> continue;
>
That one accepts everything starting with "ethernet", which sounds undesirable
if one wants to have e.g. an "ethernet-phy0" alias for some different purpose.
next prev parent reply other threads:[~2017-03-18 18:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 19:44 [U-Boot] [PATCH] fdt_support: Fixup 'ethernet' aliases not ending in digits Tuomas Tynkkynen
2017-03-18 1:26 ` Tom Rini
2017-03-18 18:20 ` Tuomas Tynkkynen [this message]
2017-03-18 18:34 ` Tom Rini
2017-03-18 23:17 ` Tuomas Tynkkynen
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=20170318202007.3c053d78@duuni \
--to=tuomas@tuxera.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