[U-Boot] [PATCH 2/3] console: unify printing current devices

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sat May 9 11:56:48 CEST 2009


actually the mpl's boards duplicate the printing current devices
from common/console.c

create stdio_print_current_devices() for this purpose

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 board/mpl/common/common_util.c |   30 -----------------------
 board/mpl/common/common_util.h |    1 -
 board/mpl/mip405/mip405.c      |    3 +-
 board/mpl/pip405/pip405.c      |    3 +-
 board/mpl/vcma9/vcma9.c        |    3 +-
 common/console.c               |   51 ++++++++++++++++++++++------------------
 include/console.h              |    2 +
 7 files changed, 36 insertions(+), 57 deletions(-)

diff --git a/board/mpl/common/common_util.c b/board/mpl/common/common_util.c
index d169391..61af4ae 100644
--- a/board/mpl/common/common_util.c
+++ b/board/mpl/common/common_util.c
@@ -29,7 +29,6 @@
 #include <asm/processor.h>
 #include <asm/byteorder.h>
 #include <i2c.h>
-#include <devices.h>
 #include <pci.h>
 #include <malloc.h>
 #include <bzlib.h>
@@ -428,35 +427,6 @@ void check_env(void)
 	}
 }
 
-
-extern device_t *stdio_devices[];
-extern char *stdio_names[];
-
-void show_stdio_dev(void)
-{
-	/* Print information */
-	puts("In:    ");
-	if (stdio_devices[stdin] == NULL) {
-		puts("No input devices available!\n");
-	} else {
-		printf ("%s\n", stdio_devices[stdin]->name);
-	}
-
-	puts("Out:   ");
-	if (stdio_devices[stdout] == NULL) {
-		puts("No output devices available!\n");
-	} else {
-		printf ("%s\n", stdio_devices[stdout]->name);
-	}
-
-	puts("Err:   ");
-	if (stdio_devices[stderr] == NULL) {
-		puts("No error devices available!\n");
-	} else {
-		printf ("%s\n", stdio_devices[stderr]->name);
-	}
-}
-
 #endif /* #if !defined(CONFIG_PATI) */
 
 int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
diff --git a/board/mpl/common/common_util.h b/board/mpl/common/common_util.h
index 46573da..29cd14f 100644
--- a/board/mpl/common/common_util.h
+++ b/board/mpl/common/common_util.h
@@ -37,7 +37,6 @@ void get_backup_values(backup_t *buf);
 #define BOOT_PCI	0x02
 #endif
 
-void show_stdio_dev(void);
 void check_env(void);
 #if defined(CONFIG_CMD_DOC)
 void doc_init (void);
diff --git a/board/mpl/mip405/mip405.c b/board/mpl/mip405/mip405.c
index 5eb90e5..732a97e 100644
--- a/board/mpl/mip405/mip405.c
+++ b/board/mpl/mip405/mip405.c
@@ -68,6 +68,7 @@
 #include <4xx_i2c.h>
 #include <miiphy.h>
 #include "../common/common_util.h"
+#include <console.h>
 #include <i2c.h>
 #include <rtc.h>
 
@@ -735,7 +736,7 @@ int last_stage_init (void)
 		printf ("Error writing to the PHY\n");
 	}
 	print_mip405_rev ();
-	show_stdio_dev ();
+	stdio_print_current_devices ();
 	check_env ();
 	/* check if RTC time is valid */
 	stop=get_timer(start);
diff --git a/board/mpl/pip405/pip405.c b/board/mpl/pip405/pip405.c
index 8724e27..c740f9d 100644
--- a/board/mpl/pip405/pip405.c
+++ b/board/mpl/pip405/pip405.c
@@ -28,6 +28,7 @@
 #include "pip405.h"
 #include <asm/processor.h>
 #include <i2c.h>
+#include <console.h>
 #include "../common/isa.h"
 #include "../common/common_util.h"
 
@@ -705,7 +706,7 @@ int last_stage_init (void)
 {
 	print_pip405_rev ();
 	isa_init ();
-	show_stdio_dev ();
+	stdio_print_current_devices ();
 	check_env();
 	return 0;
 }
diff --git a/board/mpl/vcma9/vcma9.c b/board/mpl/vcma9/vcma9.c
index a4c463a..21656e2 100644
--- a/board/mpl/vcma9/vcma9.c
+++ b/board/mpl/vcma9/vcma9.c
@@ -27,6 +27,7 @@
 
 #include <common.h>
 #include <s3c2410.h>
+#include <console.h>
 #include <i2c.h>
 
 #include "vcma9.h"
@@ -316,7 +317,7 @@ int last_stage_init(void)
 {
 	mem_test_reloc();
 	checkboard();
-	show_stdio_dev();
+	stdio_print_current_devices();
 	check_env();
 	return 0;
 }
diff --git a/common/console.c b/common/console.c
index 2add047..c1669d1 100644
--- a/common/console.c
+++ b/common/console.c
@@ -532,6 +532,33 @@ int console_init_f(void)
 	return 0;
 }
 
+void stdio_print_current_devices(void)
+{
+#ifdef CONFIG_SYS_CONSOLE_INFO_QUIET
+	/* Print information */
+	puts("In:    ");
+	if (stdio_devices[stdin] == NULL) {
+		puts("No input devices available!\n");
+	} else {
+		printf ("%s\n", stdio_devices[stdin]->name);
+	}
+
+	puts("Out:   ");
+	if (stdio_devices[stdout] == NULL) {
+		puts("No output devices available!\n");
+	} else {
+		printf ("%s\n", stdio_devices[stdout]->name);
+	}
+
+	puts("Err:   ");
+	if (stdio_devices[stderr] == NULL) {
+		puts("No error devices available!\n");
+	} else {
+		printf ("%s\n", stdio_devices[stderr]->name);
+	}
+#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
+}
+
 #ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV
 /* Called after the relocation - use desired console functions */
 int console_init_r(void)
@@ -601,29 +628,7 @@ done:
 
 	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */
 
-#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
-	/* Print information */
-	puts("In:    ");
-	if (stdio_devices[stdin] == NULL) {
-		puts("No input devices available!\n");
-	} else {
-		console_printdevs(stdin);
-	}
-
-	puts("Out:   ");
-	if (stdio_devices[stdout] == NULL) {
-		puts("No output devices available!\n");
-	} else {
-		console_printdevs(stdout);
-	}
-
-	puts("Err:   ");
-	if (stdio_devices[stderr] == NULL) {
-		puts("No error devices available!\n");
-	} else {
-		console_printdevs(stderr);
-	}
-#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
+	stdio_print_current_devices();
 
 #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
 	/* set the environment variables (will overwrite previous env settings) */
diff --git a/include/console.h b/include/console.h
index bc8b139..c58fd2b 100644
--- a/include/console.h
+++ b/include/console.h
@@ -33,4 +33,6 @@
 extern device_t	*stdio_devices[] ;
 extern char *stdio_names[MAX_FILES] ;
 
+void stdio_print_current_devices(void);
+
 #endif
-- 
1.6.1.3



More information about the U-Boot mailing list