[U-Boot] [PATCH v2] fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Kumar Gala
galak at kernel.crashing.org
Mon Aug 18 21:40:24 CEST 2008
On Aug 18, 2008, at 2:30 PM, Wolfgang Denk wrote:
> 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?
We need some upper limit to stop checking at.
>> + 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.
done, and removed the duplicated sprintf that snuck in.
>> + 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?
I dont like making this assumption and do think its too much work to
check 10 possible aliases and skip to the next one if it doesn't exist.
- k
More information about the U-Boot
mailing list