[U-Boot] [PATCH v4] fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Wolfgang Denk
wd at denx.de
Tue Aug 19 21:03:48 CEST 2008
Dear Kumar Gala,
In message <1219163066-27896-1-git-send-email-galak at kernel.crashing.org> you wrote:
> Move to using the environment variables 'ethaddr', 'eth1addr', etc..
> instead of bd->bi_enetaddr, bi_enet1addr, etc.
>
> This makes the code a bit more flexible to the number of ethernet
> interfaces.
>
> Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
> ---
>
> Iterate over the aliases since its simplier than inventing a wheel to
> iterate over the environment. This removes the hard coded limit.
Please iterate over the environment variables as discussed earlier.
I don't think there is any need to invent wheels to iterate over the
environment. It should probably be as simple as that:
char mac[16];
char *val;
int i = 0;
strcpy (mac, "ethaddr");
while ((val = getenv(mac)) != NULL) {
...
sprintf (mac, "eth%daddr", ++i);
}
I call that a loop, not a wheel :-)
> + sprintf(mac, idx ? "eth%daddr" : "ethaddr", idx);
That should generate a nasty compiler warning about number of
arguments ...
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
War is never imperative.
-- McCoy, "Balance of Terror", stardate 1709.2
More information about the U-Boot
mailing list