npe: get mac address from environment

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

The resulting code can also be simplified even further.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Stefan Roese <sr@denx.de>
CC: Ben Warren <biggerbadderben@gmail.com>
This commit is contained in:
Mike Frysinger 2009-02-11 19:19:54 -05:00 committed by Wolfgang Denk
parent 6bacfa6a8e
commit 740e8ba7d4

View File

@ -565,25 +565,19 @@ int npe_initialize(bd_t * bis)
struct eth_device *dev; struct eth_device *dev;
int eth_num = 0; int eth_num = 0;
struct npe *p_npe = NULL; struct npe *p_npe = NULL;
uchar enetaddr[6];
for (eth_num = 0; eth_num < CONFIG_SYS_NPE_NUMS; eth_num++) { for (eth_num = 0; eth_num < CONFIG_SYS_NPE_NUMS; eth_num++) {
/* See if we can actually bring up the interface, otherwise, skip it */ /* See if we can actually bring up the interface, otherwise, skip it */
switch (eth_num) {
default: /* fall through */
case 0:
if (memcmp (bis->bi_enetaddr, "\0\0\0\0\0\0", 6) == 0) {
continue;
}
break;
#ifdef CONFIG_HAS_ETH1 #ifdef CONFIG_HAS_ETH1
case 1: if (eth_num == 1) {
if (memcmp (bis->bi_enet1addr, "\0\0\0\0\0\0", 6) == 0) { if (!eth_getenv_enetaddr("eth1addr", enetaddr))
continue; continue;
} } else
break;
#endif #endif
} if (!eth_getenv_enetaddr("ethaddr", enetaddr))
continue;
/* Allocate device structure */ /* Allocate device structure */
dev = (struct eth_device *)malloc(sizeof(*dev)); dev = (struct eth_device *)malloc(sizeof(*dev));
@ -603,22 +597,14 @@ int npe_initialize(bd_t * bis)
} }
memset(p_npe, 0, sizeof(struct npe)); memset(p_npe, 0, sizeof(struct npe));
switch (eth_num) { p_npe->eth_id = eth_num;
default: /* fall through */ memcpy(dev->enetaddr, enetaddr, 6);
case 0:
memcpy(dev->enetaddr, bis->bi_enetaddr, 6);
p_npe->eth_id = 0;
p_npe->phy_no = CONFIG_PHY_ADDR;
break;
#ifdef CONFIG_HAS_ETH1 #ifdef CONFIG_HAS_ETH1
case 1: if (eth_num == 1)
memcpy(dev->enetaddr, bis->bi_enet1addr, 6);
p_npe->eth_id = 1;
p_npe->phy_no = CONFIG_PHY1_ADDR; p_npe->phy_no = CONFIG_PHY1_ADDR;
break; else
#endif #endif
} p_npe->phy_no = CONFIG_PHY_ADDR;
sprintf(dev->name, "NPE%d", eth_num); sprintf(dev->name, "NPE%d", eth_num);
dev->priv = (void *)p_npe; dev->priv = (void *)p_npe;