[U-Boot] [PATCH v2] fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Wolfgang Denk
wd at denx.de
Mon Aug 18 21:30:04 CEST 2008
Dear Kumar Gala,
In message <Pine.LNX.4.64.0808181422320.28491 at blarg.am.freescale.net> 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. Right now we assume a max of 10 interfaces.
Hm... where exactly is this artificial limit coming from? Do we really
need it?
> + for (i = 0; i < CFG_MAX_NUM_ETH; i++) {
> + sprintf(enet, "ethernet%d", i);
> + sprintf(mac, "eth%daddr",i);
> +
> + sprintf(mac, i ? "eth%daddr" : "ethaddr", i);
> + tmp = getenv(mac);
for efficientcy, make this the first action in the loop.
> + path = fdt_getprop(fdt, node, enet, NULL);
> +
> + if (!path) {
> + debug("No alias for %s\n", enet);
> + continue;
> + }
> + if (!tmp) {
> + debug("No environment variable for %s\n", mac);
> + continue;
> + }
If we assume, that all existing interfaces must have addresses
assigned, we could use a "break" here instead of the "continue". That
would be (1) much faster on most boards and (2) would allow us to get
rid of the artifical limit of 10.
What do you think?
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
Let the programmers be many and the managers few -- then all will be
productive. -- Geoffrey James, "The Tao of Programming"
More information about the U-Boot
mailing list