[U-Boot] [PATCH 1/2] serial: Remove the "serial" console device

Joe Hershberger joe.hershberger at ni.com
Thu Nov 1 22:46:27 CET 2012


Each serial device is added as a console device.  There was also the
"serial" device that points to the most-recently-assigned-to-some-
console-handle device.  This can be confusing.  Instead, only show the
actual serial devices.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
---
 common/console.c | 37 +++++++++++++++++++------------------
 common/stdio.c   | 12 +-----------
 2 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/common/console.c b/common/console.c
index 1177f7d..9cc8197 100644
--- a/common/console.c
+++ b/common/console.c
@@ -26,6 +26,7 @@
 #include <malloc.h>
 #include <stdio_dev.h>
 #include <exports.h>
+#include <serial.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -550,6 +551,7 @@ int console_assign(int file, const char *devname)
 {
 	int flag;
 	struct stdio_dev *dev;
+	const char *realdevname;
 
 	/* Check for valid file */
 	switch (file) {
@@ -565,8 +567,12 @@ int console_assign(int file, const char *devname)
 	}
 
 	/* Check for valid device name */
+	if (strcmp(devname, "serial") == 0)
+		realdevname = default_serial_console()->name;
+	else
+		realdevname = devname;
 
-	dev = search_device(flag, devname);
+	dev = search_device(flag, realdevname);
 
 	if (dev)
 		return console_setfile(file, dev);
@@ -657,13 +663,16 @@ int console_init_r(void)
 	}
 	/* if the devices are overwritten or not found, use default device */
 	if (inputdev == NULL) {
-		inputdev  = search_device(DEV_FLAGS_INPUT,  "serial");
+		inputdev  = search_device(DEV_FLAGS_INPUT,
+			default_serial_console()->name);
 	}
 	if (outputdev == NULL) {
-		outputdev = search_device(DEV_FLAGS_OUTPUT, "serial");
+		outputdev = search_device(DEV_FLAGS_OUTPUT,
+			default_serial_console()->name);
 	}
 	if (errdev == NULL) {
-		errdev    = search_device(DEV_FLAGS_OUTPUT, "serial");
+		errdev = search_device(DEV_FLAGS_OUTPUT,
+			default_serial_console()->name);
 	}
 	/* Initializes output console first */
 	if (outputdev != NULL) {
@@ -713,18 +722,10 @@ int console_init_r(void)
 	struct list_head *pos;
 	struct stdio_dev *dev;
 
-#ifdef CONFIG_SPLASH_SCREEN
-	/*
-	 * suppress all output if splash screen is enabled and we have
-	 * a bmp to display. We redirect the output from frame buffer
-	 * console to serial console in this case or suppress it if
-	 * "silent" mode was requested.
-	 */
-	if (getenv("splashimage") != NULL) {
-		if (!(gd->flags & GD_FLG_SILENT))
-			outputdev = search_device (DEV_FLAGS_OUTPUT, "serial");
-	}
-#endif
+	outputdev = search_device(DEV_FLAGS_OUTPUT,
+		default_serial_console()->name);
+	inputdev = search_device(DEV_FLAGS_INPUT,
+		default_serial_console()->name);
 
 	/* Scan devices looking for input and output devices */
 	list_for_each(pos, list) {
@@ -760,13 +761,13 @@ int console_init_r(void)
 
 	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */
 
-	stdio_print_current_devices();
-
 	/* Setting environment variables */
 	for (i = 0; i < 3; i++) {
 		setenv(stdio_names[i], stdio_devices[i]->name);
 	}
 
+	stdio_print_current_devices();
+
 #if 0
 	/* If nothing usable installed, use only the initial console */
 	if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
diff --git a/common/stdio.c b/common/stdio.c
index 605ff3f..e9bdc0e 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -70,21 +70,11 @@ int nulldev_input(void)
 
 static void drv_system_init (void)
 {
+#ifdef CONFIG_SYS_DEVICE_NULLDEV
 	struct stdio_dev dev;
 
 	memset (&dev, 0, sizeof (dev));
 
-	strcpy (dev.name, "serial");
-	dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
-	dev.putc = serial_putc;
-	dev.puts = serial_puts;
-	dev.getc = serial_getc;
-	dev.tstc = serial_tstc;
-	stdio_register (&dev);
-
-#ifdef CONFIG_SYS_DEVICE_NULLDEV
-	memset (&dev, 0, sizeof (dev));
-
 	strcpy (dev.name, "nulldev");
 	dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
 	dev.putc = nulldev_putc;
-- 
1.7.11.5



More information about the U-Boot mailing list