[U-Boot] change fdt_fixup_ethernet to use env instead of bd_t
Kumar Gala
galak at kernel.crashing.org
Mon Aug 18 20:26:51 CEST 2008
Does anyone see any issue with moving to using the environment instead of
the bd_t to get the mac address for a given ethernet controller. This has
the benefit of having this bit of code scales easier w/the # of
controllers.
Right now I've set the max to 10, but we can easily make it configurable.
- k
void fdt_fixup_ethernet(void *fdt)
{
int i, j;
int node;
const char *path;
node = fdt_path_offset(fdt, "/aliases");
if (node >= 0) {
char enet[12], mac[10], *tmp, *end;
unsigned char mac_addr[6];
for (i = 0; i < 10; i++) {
sprintf(enet, "ethernet%d", i);
sprintf(mac, "eth%daddr",i);
sprintf(mac, i ? "eth%daddr" : "ethaddr", i);
tmp = getenv(mac);
path = fdt_getprop(fdt, node, enet, NULL);
if (!path) {
continue;
}
if (!tmp) {
continue;
}
for (j = 0; j < 6; j++) {
mac_addr[j] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
if (tmp)
tmp = (*end) ? end+1 : end;
}
do_fixup_by_path(fdt, path, "mac-address",
&mac_addr, 6, 0);
do_fixup_by_path(fdt, path, "local-mac-address",
&mac_addr, 6, 1);
}
}
}
More information about the U-Boot
mailing list