public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Add background serial print and correct search_device function
@ 2008-08-20 16:58 Ryan CHEN
  2008-09-06 15:48 ` Wolfgang Denk
  2008-09-06 18:29 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 3+ messages in thread
From: Ryan CHEN @ 2008-08-20 16:58 UTC (permalink / raw)
  To: u-boot

The patch introduces a new macro 'CFG_BG_CONSOLE_SERIAL'.
It means print messages through serial port although current console isn't serial port.
It is important for debugging and looks like multi-consoles in Linux but without input.

Another modification in the patch is that verify if search_device function found device. 
If found, return dev. Otherwise, return NULL.

Signed-off-by: Ryan Chen <ryan.chen@st.com>

---
 common/console.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/common/console.c b/common/console.c
index 1b095b1..c60baef 100644
--- a/common/console.c
+++ b/common/console.c
@@ -132,12 +132,20 @@ void fputc (int file, const char c)
 {
 	if (file < MAX_FILES)
 		stdio_devices[file]->putc (c);
+#ifdef CFG_BG_CONSOLE_SERIAL
+	if((unsigned int)stdio_devices[file]->putc != (unsigned int)serial_putc)
+		serial_putc (c);
+#endif/*CFG_BG_CONSOLE_SERIAL*/
 }
 
 void fputs (int file, const char *s)
 {
 	if (file < MAX_FILES)
 		stdio_devices[file]->puts (s);
+#ifdef CFG_BG_CONSOLE_SERIAL
+	if((unsigned int)stdio_devices[file]->puts != (unsigned int)serial_puts)
+		serial_puts(s);
+#endif/*CFG_BG_CONSOLE_SERIAL*/
 }
 
 void fprintf (int file, const char *fmt, ...)
@@ -377,6 +385,7 @@ device_t *search_device (int flags, char *name)
 {
 	int i, items;
 	device_t *dev = NULL;
+	int found_flag = 0;
 
 	items = ListNumItems (devlist);
 	if (name == NULL)
@@ -385,9 +394,13 @@ device_t *search_device (int flags, char *name)
 	for (i = 1; i <= items; i++) {
 		dev = ListGetPtrToItem (devlist, i);
 		if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) {
+			found_flag = 1;
 			break;
 		}
 	}
+	
+	if(!found_flag)
+		return NULL;
 	return dev;
 }
 #endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
-- 
1.6.0.rc1

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

end of thread, other threads:[~2008-09-06 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-20 16:58 [U-Boot] [PATCH] Add background serial print and correct search_device function Ryan CHEN
2008-09-06 15:48 ` Wolfgang Denk
2008-09-06 18:29 ` Jean-Christophe PLAGNIOL-VILLARD

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