[U-Boot] [PATCH] mvgbe: remove setting of ethaddr within the driver

Michael Walle michael at walle.cc
Mon Nov 7 23:08:09 CET 2011


A network driver should not touch the environment at all. This patch fixes
this behaviour by removing the code for setting a default/randomized MAC
address.

Instead a board should either set CONFIG_ETHADDR, CONFIG_ETH1ADDR etc. or
use some specific code within the board files, eg. if randomization is
needed.

All boards which have CONFIG_SKIP_LOCAL_MAC_RANDOMIZATION set (actually its
only one board, edminiv2) are converted to use CONFIG_ETHADDR. Please check
your boards whether you really need randomization support or the
CONFIG_ETHADDR macro is enough.

Signed-off-by: Michael Walle <michael at walle.cc>
Cc: Mike Frysinger <vapier at gentoo.org>
Cc: Valentin Longchamp <valentin.longchamp at keymile.com>
Cc: Eric Cooper <ecc at cmu.edu>
Cc: Jason Cooper <u-boot at lakedaemon.net>
Cc: Siddarth Gore <gores at marvell.com>
Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
Cc: Prafulla Wadaskar <prafulla at marvell.com>
Cc: Simon Guinot <simon.guinot at sequanux.org>
---
 drivers/net/mvgbe.c        |   23 -----------------------
 include/configs/edminiv2.h |    2 +-
 2 files changed, 1 insertions(+), 24 deletions(-)

diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c
index c7f7446..21be642 100644
--- a/drivers/net/mvgbe.c
+++ b/drivers/net/mvgbe.c
@@ -647,7 +647,6 @@ int mvgbe_initialize(bd_t *bis)
 	struct mvgbe_device *dmvgbe;
 	struct eth_device *dev;
 	int devnum;
-	char *s;
 	u8 used_ports[MAX_MVGBE_DEVS] = CONFIG_MVGBE_PORTS;
 
 	for (devnum = 0; devnum < MAX_MVGBE_DEVS; devnum++) {
@@ -702,16 +701,13 @@ error1:
 		/* must be less than NAMESIZE (16) */
 		sprintf(dev->name, "egiga%d", devnum);
 
-		/* Extract the MAC address from the environment */
 		switch (devnum) {
 		case 0:
 			dmvgbe->regs = (void *)MVGBE0_BASE;
-			s = "ethaddr";
 			break;
 #if defined(MVGBE1_BASE)
 		case 1:
 			dmvgbe->regs = (void *)MVGBE1_BASE;
-			s = "eth1addr";
 			break;
 #endif
 		default:	/* this should never happen */
@@ -720,25 +716,6 @@ error1:
 			return -1;
 		}
 
-		while (!eth_getenv_enetaddr(s, dev->enetaddr)) {
-			/* Generate Private MAC addr if not set */
-			dev->enetaddr[0] = 0x02;
-			dev->enetaddr[1] = 0x50;
-			dev->enetaddr[2] = 0x43;
-#if defined (CONFIG_SKIP_LOCAL_MAC_RANDOMIZATION)
-			/* Generate fixed lower MAC half using devnum */
-			dev->enetaddr[3] = 0;
-			dev->enetaddr[4] = 0;
-			dev->enetaddr[5] = devnum;
-#else
-			/* Generate random lower MAC half */
-			dev->enetaddr[3] = get_random_hex();
-			dev->enetaddr[4] = get_random_hex();
-			dev->enetaddr[5] = get_random_hex();
-#endif
-			eth_setenv_enetaddr(s, dev->enetaddr);
-		}
-
 		dev->init = (void *)mvgbe_init;
 		dev->halt = (void *)mvgbe_halt;
 		dev->send = (void *)mvgbe_send;
diff --git a/include/configs/edminiv2.h b/include/configs/edminiv2.h
index 88d32b2..2b96cb3 100644
--- a/include/configs/edminiv2.h
+++ b/include/configs/edminiv2.h
@@ -142,7 +142,7 @@
 #ifdef CONFIG_CMD_NET
 #define CONFIG_MVGBE				/* Enable Marvell GbE Driver */
 #define CONFIG_MVGBE_PORTS	{1}		/* enable port 0 only */
-#define CONFIG_SKIP_LOCAL_MAC_RANDOMIZATION	/* don't randomize MAC */
+#define CONFIG_ETH_ADDR 02:50:43:00:00:01
 #define CONFIG_PHY_BASE_ADR	0x8
 #define CONFIG_RESET_PHY_R	/* use reset_phy() to init mv8831116 PHY */
 #define CONFIG_NETCONSOLE	/* include NetConsole support   */
-- 
1.7.2.5



More information about the U-Boot mailing list