public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] simplify silent console
@ 2006-07-25 15:30 Ladislav Michl
  2006-10-30  8:25 ` Stefan Roese
  0 siblings, 1 reply; 5+ messages in thread
From: Ladislav Michl @ 2006-07-25 15:30 UTC (permalink / raw)
  To: u-boot

Wolfgang,

silent console output is currently implemented by assigning nulldev
as output device. This is a bit overcomplicated, since there is
also GD_FLG_SILENT flag.

Patch bellow tries to simplify silencing console by honouring
GD_FLG_SILENT in console output functions, so there is no need to
mess with output device. Comments?

Best regards,
	ladis

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>

CHANGELOG
* Silent console code simplification.
  Patch by Ladislav Michl, 25 Jul 2006


diff --git a/common/console.c b/common/console.c
index e9f23be..d8a0cb6 100644
--- a/common/console.c
+++ b/common/console.c
@@ -494,13 +494,7 @@ #ifdef CONFIG_SPLASH_SCREEN
 	/* suppress all output if splash screen is enabled and we have
 	   a bmp to display                                            */
 	if (getenv("splashimage") != NULL)
-		outputdev = search_device (DEV_FLAGS_OUTPUT, "nulldev");
-#endif
-
-#ifdef CONFIG_SILENT_CONSOLE
-	/* Suppress all output if "silent" mode requested		*/
-	if (gd->flags & GD_FLG_SILENT)
-		outputdev = search_device (DEV_FLAGS_OUTPUT, "nulldev");
+		gd->flags |= GD_FLG_SILENT;
 #endif
 
 	/* Scan devices looking for input and output devices */
diff --git a/common/main.c b/common/main.c
index ef28b3f..1ff3296 100644
--- a/common/main.c
+++ b/common/main.c
@@ -113,15 +113,17 @@ static __inline__ int abortboot(int boot
 	u_int i;
 
 #ifdef CONFIG_SILENT_CONSOLE
+	int silent = 0;
+
 	if (gd->flags & GD_FLG_SILENT) {
-		/* Restore serial console */
-		console_assign (stdout, "serial");
-		console_assign (stderr, "serial");
+		/* Restore console */
+		gd->flags &= ~GD_FLG_SILENT;
+		silent = 1;
 	}
 #endif
 
 #  ifdef CONFIG_AUTOBOOT_PROMPT
-	printf (CONFIG_AUTOBOOT_PROMPT, bootdelay);
+	serial_printf (CONFIG_AUTOBOOT_PROMPT, bootdelay);
 #  endif
 
 #  ifdef CONFIG_AUTOBOOT_DELAY_STR
@@ -199,14 +201,8 @@ #  if DEBUG_BOOTKEYS
 #  endif
 
 #ifdef CONFIG_SILENT_CONSOLE
-	if (abort) {
-		/* permanently enable normal console output */
-		gd->flags &= ~(GD_FLG_SILENT);
-	} else if (gd->flags & GD_FLG_SILENT) {
-		/* Restore silent console */
-		console_assign (stdout, "nulldev");
-		console_assign (stderr, "nulldev");
-	}
+	if (!abort && silent)
+		gd->flags |= GD_FLG_SILENT;
 #endif
 
 	return abort;
@@ -223,10 +219,12 @@ static __inline__ int abortboot(int boot
 	int abort = 0;
 
 #ifdef CONFIG_SILENT_CONSOLE
+	int silent = 0;
+
 	if (gd->flags & GD_FLG_SILENT) {
-		/* Restore serial console */
-		console_assign (stdout, "serial");
-		console_assign (stderr, "serial");
+		/* Restore output */
+		silent = 1;
+		gd->flags &= ~GD_FLG_SILENT;
 	}
 #endif
 
@@ -275,14 +273,8 @@ # endif
 	putc ('\n');
 
 #ifdef CONFIG_SILENT_CONSOLE
-	if (abort) {
-		/* permanently enable normal console output */
-		gd->flags &= ~(GD_FLG_SILENT);
-	} else if (gd->flags & GD_FLG_SILENT) {
-		/* Restore silent console */
-		console_assign (stdout, "nulldev");
-		console_assign (stderr, "nulldev");
-	}
+	if (!abort && silent)
+		gd->flags |= GD_FLG_SILENT;
 #endif
 
 	return abort;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-04-24 12:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-25 15:30 [U-Boot-Users] [PATCH] simplify silent console Ladislav Michl
2006-10-30  8:25 ` Stefan Roese
2007-04-24 12:02   ` Ladislav Michl
2007-04-24 12:10     ` Wolfgang Denk
2007-04-24 12:25       ` Ladislav Michl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox