Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jan 2011 23:40:13 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218050 - head/sys/dev/tsec
Message-ID:  <201101282340.p0SNeDIk004816@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Fri Jan 28 23:40:13 2011
New Revision: 218050
URL: http://svn.freebsd.org/changeset/base/218050

Log:
  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.

Modified:
  head/sys/dev/tsec/if_tsec_fdt.c

Modified: head/sys/dev/tsec/if_tsec_fdt.c
==============================================================================
--- head/sys/dev/tsec/if_tsec_fdt.c	Fri Jan 28 22:35:46 2011	(r218049)
+++ head/sys/dev/tsec/if_tsec_fdt.c	Fri Jan 28 23:40:13 2011	(r218050)
@@ -320,17 +320,15 @@ tsec_get_hwaddr(struct tsec_softc *sc, u
 	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, u
 	 * 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];
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101282340.p0SNeDIk004816>