[U-Boot] [PATCH 2/2] net: move bootfile init into eth_initialize

Mike Frysinger vapier at gentoo.org
Tue Jan 17 03:10:12 CET 2012


All arches init this the same way, so move the logic into the core
net code to avoid duplicating it everywhere else.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 arch/arm/lib/board.c        |    8 --------
 arch/avr32/lib/board.c      |    3 ---
 arch/blackfin/lib/board.c   |    7 +------
 arch/m68k/lib/board.c       |    5 -----
 arch/microblaze/lib/board.c |    4 ----
 arch/mips/lib/board.c       |    8 --------
 arch/nds32/lib/board.c      |    6 ------
 arch/powerpc/lib/board.c    |    8 --------
 arch/sh/lib/board.c         |   11 ++---------
 arch/sparc/lib/board.c      |    5 -----
 arch/x86/lib/board.c        |    6 ------
 net/eth.c                   |   10 ++++++++++
 12 files changed, 13 insertions(+), 68 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index e611ada..2c4276b 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -573,14 +573,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
-#if defined(CONFIG_CMD_NET)
-	{
-		char *s = getenv("bootfile");
-
-		if (s != NULL)
-			copy_filename(BootFile, s, sizeof(BootFile));
-	}
-#endif
 
 #ifdef CONFIG_BOARD_LATE_INIT
 	board_late_init();
diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index be5da90..4bc3c8a 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -315,9 +315,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 	bb_miiphy_init();
 #endif
 #if defined(CONFIG_CMD_NET)
-	s = getenv("bootfile");
-	if (s)
-		copy_filename(BootFile, s, sizeof(BootFile));
 	puts("Net:   ");
 	eth_initialize(gd->bd);
 #endif
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index 5d9d448..1ee7e22 100644
--- a/arch/blackfin/lib/board.c
+++ b/arch/blackfin/lib/board.c
@@ -293,13 +293,8 @@ static void board_net_init_r(bd_t *bd)
 	bb_miiphy_init();
 #endif
 #ifdef CONFIG_CMD_NET
-	char *s;
-
-	if ((s = getenv("bootfile")) != NULL)
-		copy_filename(BootFile, s, sizeof(BootFile));
-
 	printf("Net:   ");
-	eth_initialize(gd->bd);
+	eth_initialize(bd);
 #endif
 }
 
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index e80d853..b3dca77 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -559,11 +559,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
-#if defined(CONFIG_CMD_NET)
-	if ((s = getenv ("bootfile")) != NULL) {
-		copy_filename (BootFile, s, sizeof (BootFile));
-	}
-#endif
 
 	WATCHDOG_RESET ();
 
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index beb406d..f3679d5 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -182,10 +182,6 @@ void board_init (void)
 	uchar enetaddr[6];
 	eth_getenv_enetaddr("ethaddr", enetaddr);
 	printf("MAC:   %pM\n", enetaddr);
-
-	s = getenv("bootfile");
-	if (s != NULL)
-		copy_filename(BootFile, s, sizeof(BootFile));
 #endif
 
 	/* main_loop */
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index 2f45562..6b36a98 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -335,14 +335,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
-#if defined(CONFIG_CMD_NET)
-	{
-		char *s = getenv("bootfile");
-
-		if (s != NULL)
-			copy_filename(BootFile, s, sizeof(BootFile));
-	}
-#endif
 
 #ifdef CONFIG_CMD_SPI
 	puts("SPI:   ");
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index 46f022a..446e0fd 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -398,12 +398,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
 
-#if defined(CONFIG_CMD_NET)
-	s = getenv("bootfile");
-	if (s != NULL)
-		copy_filename(BootFile, s, sizeof(BootFile));
-#endif
-
 #ifdef BOARD_LATE_INIT
 	board_late_init();
 #endif
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index d4cbb4d..931b098 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -932,14 +932,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
-#if defined(CONFIG_CMD_NET)
-	{
-		char *s = getenv("bootfile");
-
-		if (s != NULL)
-			copy_filename(BootFile, s, sizeof(BootFile));
-	}
-#endif
 
 	WATCHDOG_RESET();
 
diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index cb34c0b..e1a5739 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -189,15 +189,8 @@ void sh_generic_init(void)
 	bb_miiphy_init();
 #endif
 #if defined(CONFIG_CMD_NET)
-	{
-		char *s;
-		puts("Net:   ");
-		eth_initialize(gd->bd);
-
-		s = getenv("bootfile");
-		if (s != NULL)
-			copy_filename(BootFile, s, sizeof(BootFile));
-	}
+	puts("Net:   ");
+	eth_initialize(gd->bd);
 #endif /* CONFIG_CMD_NET */
 
 	while (1) {
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index cd5cd52..a36f165 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -357,11 +357,6 @@ void board_init_f(ulong bootflag)
 
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
-#if defined(CONFIG_CMD_NET)
-	if ((s = getenv("bootfile")) != NULL) {
-		copy_filename(BootFile, s, sizeof(BootFile));
-	}
-#endif /* CONFIG_CMD_NET */
 
 	WATCHDOG_RESET();
 
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index a0c22b1..595b3c9 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -367,12 +367,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* Initialize from environment */
 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
-#if defined(CONFIG_CMD_NET)
-	s = getenv("bootfile");
-
-	if (s != NULL)
-		copy_filename(BootFile, s, sizeof(BootFile));
-#endif
 
 	WATCHDOG_RESET();
 
diff --git a/net/eth.c b/net/eth.c
index f3a55ba..83ad814 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -224,6 +224,14 @@ int eth_register(struct eth_device *dev)
 	return 0;
 }
 
+static void eth_env_init(bd_t *bis)
+{
+	const char *s;
+
+	if ((s = getenv("bootfile")) != NULL)
+		copy_filename(BootFile, s, sizeof(BootFile));
+}
+
 int eth_initialize(bd_t *bis)
 {
 	int num_devices = 0;
@@ -239,6 +247,8 @@ int eth_initialize(bd_t *bis)
 	phy_init();
 #endif
 
+	eth_env_init(bis);
+
 	/*
 	 * If board-specific initialization exists, call it.
 	 * If not, call a CPU-specific one
-- 
1.7.8.3



More information about the U-Boot mailing list