summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorBen Warren <biggerbadderben@gmail.com>2010-04-26 11:11:46 -0700
committerBen Warren <biggerbadderben@gmail.com>2010-05-03 14:52:49 -0700
commitecee9324d73555e744593f3e0d387bec4c566f55 (patch)
treee0ddc06decbe33b90c867d1751272e933f5e01ec /net
parentc960b13ed22d9ea570957379f9f7f2f37d87ef08 (diff)
Program net device MAC addresses after initializing
Add a new function to the eth_device struct for programming a network controller's hardware address. After all network devices have been initialized and the proper MAC address for each has been determined, make a device driver call to program the address into the device. Only device instances with valid unicast addresses will be programmed. Signed-off-by: Ben Warren <biggerbadderben@gmail.com> Acked-by: Detlev Zundel <dzu@denx.de> Tested-by: Prafulla Wadaskar <prafulla@marvell.com> Tested-by: Heiko Schocher <hs@denx.de> Tested-by: Thomas Chou <thomas@wytron.com.tw>
Diffstat (limited to 'net')
-rw-r--r--net/eth.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/eth.c b/net/eth.c
index aff698724d9..45e4a26d6fc 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -60,6 +60,14 @@ int eth_getenv_enetaddr_by_index(int index, uchar *enetaddr)
return eth_getenv_enetaddr(enetvar, enetaddr);
}
+static int eth_mac_skip(int index)
+{
+ char enetvar[15];
+ char *skip_state;
+ sprintf(enetvar, index ? "eth%dmacskip" : "ethmacskip", index);
+ return ((skip_state = getenv(enetvar)) != NULL);
+}
+
#ifdef CONFIG_NET_MULTI
/*
@@ -242,6 +250,11 @@ int eth_initialize(bd_t *bis)
memcpy(dev->enetaddr, env_enetaddr, 6);
}
+ if (dev->write_hwaddr &&
+ !eth_mac_skip(eth_number) &&
+ is_valid_ether_addr(dev->enetaddr)) {
+ dev->write_hwaddr(dev);
+ }
eth_number++;
dev = dev->next;