summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2011-01-28 23:40:13 +0000
committermarcel <marcel@FreeBSD.org>2011-01-28 23:40:13 +0000
commitf21f4925102ebdfd428aba8a1ca65c3af9af65e9 (patch)
treeedbb102e5f3cf935d31258450f6897554cbe8c63
parent621f7543a982007a0186cee91e51e29ff13e6630 (diff)
downloadFreeBSD-src-f21f4925102ebdfd428aba8a1ca65c3af9af65e9.zip
FreeBSD-src-f21f4925102ebdfd428aba8a1ca65c3af9af65e9.tar.gz
Don't use the MAC address in the device tree if it's all zeroes
(i.e. 00-00-00-00-00-00). Use the currently programmed address instead. While here, simplify the function.
-rw-r--r--sys/dev/tsec/if_tsec_fdt.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/sys/dev/tsec/if_tsec_fdt.c b/sys/dev/tsec/if_tsec_fdt.c
index e355e61..b320a25 100644
--- a/sys/dev/tsec/if_tsec_fdt.c
+++ b/sys/dev/tsec/if_tsec_fdt.c
@@ -320,17 +320,15 @@ tsec_get_hwaddr(struct tsec_softc *sc, uint8_t *addr)
union {
uint32_t reg[2];
uint8_t addr[6];
- } curmac;
- uint32_t a[6];
- uint8_t lma[6];
+ } hw;
int i;
- /*
- * Retrieve hw address from the device tree.
- */
- i = OF_getprop(sc->node, "local-mac-address", (void *)lma, 6);
- if (i == 6) {
- bcopy(lma, addr, 6);
+ hw.reg[0] = hw.reg[1] = 0;
+
+ /* Retrieve the hardware address from the device tree. */
+ i = OF_getprop(sc->node, "local-mac-address", (void *)hw.addr, 6);
+ if (i == 6 && (hw.reg[0] != 0 || hw.reg[1] != 0)) {
+ bcopy(hw.addr, addr, 6);
return;
}
@@ -338,15 +336,8 @@ tsec_get_hwaddr(struct tsec_softc *sc, uint8_t *addr)
* Fall back -- use the currently programmed address in the hope that
* it was set be firmware...
*/
- curmac.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1);
- curmac.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2);
+ hw.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1);
+ hw.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2);
for (i = 0; i < 6; i++)
- a[5-i] = curmac.addr[i];
-
- addr[0] = a[0];
- addr[1] = a[1];
- addr[2] = a[2];
- addr[3] = a[3];
- addr[4] = a[4];
- addr[5] = a[5];
+ addr[5-i] = hw.addr[i];
}
OpenPOWER on IntegriCloud