[U-Boot] [PATCH 1/2] common/console: coding style cleanup

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sun Feb 1 12:12:50 CET 2009


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 common/console.c |   97 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 50 insertions(+), 47 deletions(-)

diff --git a/common/console.c b/common/console.c
index 89aeab6..851b0f8 100644
--- a/common/console.c
+++ b/common/console.c
@@ -106,39 +106,39 @@ int cd_count[MAX_FILES];
  * only from fgetc() which assures it.
  * No attempt is made to demultiplex multiple input sources.
  */
-static int iomux_getc(void)
+static int iomux_getc (void)
 {
 	unsigned char ret;
 
 	/* This is never called with testcdev == NULL */
-	ret = tstcdev->getc();
+	ret = tstcdev->getc ();
 	tstcdev = NULL;
 	return ret;
 }
 
-static int iomux_tstc(int file)
+static int iomux_tstc (int file)
 {
 	int i, ret;
 	device_t *dev;
 
-	disable_ctrlc(1);
+	disable_ctrlc (1);
 	for (i = 0; i < cd_count[file]; i++) {
 		dev = console_devices[file][i];
 		if (dev->tstc != NULL) {
-			ret = dev->tstc();
+			ret = dev->tstc ();
 			if (ret > 0) {
 				tstcdev = dev;
-				disable_ctrlc(0);
+				disable_ctrlc (0);
 				return ret;
 			}
 		}
 	}
-	disable_ctrlc(0);
+	disable_ctrlc (0);
 
 	return 0;
 }
 
-static void iomux_putc(int file, const char c)
+static void iomux_putc (int file, const char c)
 {
 	int i;
 	device_t *dev;
@@ -146,11 +146,11 @@ static void iomux_putc(int file, const char c)
 	for (i = 0; i < cd_count[file]; i++) {
 		dev = console_devices[file][i];
 		if (dev->putc != NULL)
-			dev->putc(c);
+			dev->putc (c);
 	}
 }
 
-static void iomux_puts(int file, const char *s)
+static void iomux_puts (int file, const char *s)
 {
 	int i;
 	device_t *dev;
@@ -158,7 +158,7 @@ static void iomux_puts(int file, const char *s)
 	for (i = 0; i < cd_count[file]; i++) {
 		dev = console_devices[file][i];
 		if (dev->puts != NULL)
-			dev->puts(s);
+			dev->puts (s);
 	}
 }
 #endif /* defined(CONFIG_CONSOLE_MUX) */
@@ -195,14 +195,14 @@ int fgetc (int file)
 			 * check for that first.
 			 */
 			if (tstcdev != NULL)
-				return iomux_getc();
-			iomux_tstc(file);
+				return iomux_getc ();
+			iomux_tstc (file);
 #ifdef CONFIG_WATCHDOG
 			/*
 			 * If the watchdog must be rate-limited then it should
 			 * already be handled in board-specific code.
 			 */
-			 udelay(1);
+			 udelay (1);
 #endif
 		}
 #else
@@ -217,7 +217,7 @@ int ftstc (int file)
 {
 	if (file < MAX_FILES)
 #if defined(CONFIG_CONSOLE_MUX)
-		return iomux_tstc(file);
+		return iomux_tstc (file);
 #else
 		return stdio_devices[file]->tstc ();
 #endif
@@ -229,7 +229,7 @@ void fputc (int file, const char c)
 {
 	if (file < MAX_FILES)
 #if defined(CONFIG_CONSOLE_MUX)
-		iomux_putc(file, c);
+		iomux_putc (file, c);
 #else
 		stdio_devices[file]->putc (c);
 #endif
@@ -239,7 +239,7 @@ void fputs (int file, const char *s)
 {
 	if (file < MAX_FILES)
 #if defined(CONFIG_CONSOLE_MUX)
-		iomux_puts(file, s);
+		iomux_puts (file, s);
 #else
 		stdio_devices[file]->puts (s);
 #endif
@@ -415,35 +415,36 @@ void clear_ctrlc (void)
 char	screen[1024];
 char *cursor = screen;
 int once = 0;
-inline void dbg(const char *fmt, ...)
+inline void dbg (const char *fmt, ...)
 {
 	va_list	args;
 	uint	i;
 	char	printbuffer[CONFIG_SYS_PBSIZE];
 
 	if (!once) {
-		memset(screen, 0, sizeof(screen));
+		memset (screen, 0, sizeof (screen));
 		once++;
 	}
 
-	va_start(args, fmt);
+	va_start (args, fmt);
 
 	/* For this to work, printbuffer must be larger than
 	 * anything we ever want to print.
 	 */
-	i = vsprintf(printbuffer, fmt, args);
-	va_end(args);
+	i = vsprintf (printbuffer, fmt, args);
+	va_end (args);
 
-	if ((screen + sizeof(screen) - 1 - cursor) < strlen(printbuffer)+1) {
-		memset(screen, 0, sizeof(screen));
+	if ((screen + sizeof (screen) - 1 - cursor)
+	    < strlen (printbuffer) + 1) {
+		memset (screen, 0, sizeof (screen));
 		cursor = screen;
 	}
-	sprintf(cursor, printbuffer);
-	cursor += strlen(printbuffer);
+	sprintf (cursor, printbuffer);
+	cursor += strlen (printbuffer);
 
 }
 #else
-inline void dbg(const char *fmt, ...)
+inline void dbg (const char *fmt, ...)
 {
 }
 #endif
@@ -454,9 +455,9 @@ device_t *search_device (int flags, char *name)
 {
 	device_t *dev;
 
-	dev = device_get_by_name(name);
+	dev = device_get_by_name (name);
 
-	if(dev && (dev->flags & flags))
+	if (dev && (dev->flags & flags))
 		return dev;
 
 	return NULL;
@@ -482,9 +483,9 @@ int console_assign (int file, char *devname)
 
 	/* Check for valid device name */
 
-	dev = search_device(flag, devname);
+	dev = search_device (flag, devname);
 
-	if(dev)
+	if (dev)
 		return console_setfile (file, dev);
 
 	return -1;
@@ -496,7 +497,7 @@ int console_init_f (void)
 	gd->have_console = 1;
 
 #ifdef CONFIG_SILENT_CONSOLE
-	if (getenv("silent") != NULL)
+	if (getenv ("silent") != NULL)
 		gd->flags |= GD_FLG_SILENT;
 #endif
 
@@ -534,9 +535,9 @@ int console_init_r (void)
 		outputdev = search_device (DEV_FLAGS_OUTPUT, stdoutname);
 		errdev    = search_device (DEV_FLAGS_OUTPUT, stderrname);
 #ifdef CONFIG_CONSOLE_MUX
-		iomux_err = iomux_doenv(stdin, stdinname);
-		iomux_err += iomux_doenv(stdout, stdoutname);
-		iomux_err += iomux_doenv(stderr, stderrname);
+		iomux_err = iomux_doenv (stdin, stdinname);
+		iomux_err += iomux_doenv (stdout, stdoutname);
+		iomux_err += iomux_doenv (stderr, stderrname);
 		if (!iomux_err)
 			/* Successful, so skip all the code below. */
 			goto done;
@@ -556,7 +557,7 @@ int console_init_r (void)
 	if (outputdev != NULL) {
 #ifdef CONFIG_CONSOLE_MUX
 		/* need to set a console if not done above. */
-		iomux_doenv(stdout, outputdev->name);
+		iomux_doenv (stdout, outputdev->name);
 #else
 		console_setfile (stdout, outputdev);
 #endif
@@ -564,7 +565,7 @@ int console_init_r (void)
 	if (errdev != NULL) {
 #ifdef CONFIG_CONSOLE_MUX
 		/* need to set a console if not done above. */
-		iomux_doenv(stderr, errdev->name);
+		iomux_doenv (stderr, errdev->name);
 #else
 		console_setfile (stderr, errdev);
 #endif
@@ -572,7 +573,7 @@ int console_init_r (void)
 	if (inputdev != NULL) {
 #ifdef CONFIG_CONSOLE_MUX
 		/* need to set a console if not done above. */
-		iomux_doenv(stdin, inputdev->name);
+		iomux_doenv (stdin, inputdev->name);
 #else
 		console_setfile (stdin, inputdev);
 #endif
@@ -591,7 +592,7 @@ done:
 		puts ("No input devices available!\n");
 	} else {
 #ifdef CONFIG_CONSOLE_MUX
-		iomux_printdevs(stdin);
+		iomux_printdevs (stdin);
 #else
 		printf ("%s\n", stdio_devices[stdin]->name);
 #endif
@@ -602,7 +603,7 @@ done:
 		puts ("No output devices available!\n");
 	} else {
 #ifdef CONFIG_CONSOLE_MUX
-		iomux_printdevs(stdout);
+		iomux_printdevs (stdout);
 #else
 		printf ("%s\n", stdio_devices[stdout]->name);
 #endif
@@ -613,7 +614,7 @@ done:
 		puts ("No error devices available!\n");
 	} else {
 #ifdef CONFIG_CONSOLE_MUX
-		iomux_printdevs(stderr);
+		iomux_printdevs (stderr);
 #else
 		printf ("%s\n", stdio_devices[stderr]->name);
 #endif
@@ -642,20 +643,22 @@ int console_init_r (void)
 {
 	device_t *inputdev = NULL, *outputdev = NULL;
 	int i;
-	struct list_head *list = device_get_list();
+	struct list_head *list = device_get_list ();
 	struct list_head *pos;
 	device_t *dev;
 
 #ifdef CONFIG_SPLASH_SCREEN
-	/* suppress all output if splash screen is enabled and we have
-	   a bmp to display                                            */
-	if (getenv("splashimage") != NULL)
+	/*
+	 * suppress all output if splash screen is enabled and we have
+	 * a bmp to display
+	 */
+	if (getenv ("splashimage") != NULL)
 		gd->flags |= GD_FLG_SILENT;
 #endif
 
 	/* Scan devices looking for input and output devices */
-	list_for_each(pos, list) {
-		dev = list_entry(pos, device_t, list);
+	list_for_each (pos, list) {
+		dev = list_entry (pos, device_t, list);
 
 		if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) {
 			inputdev = dev;
-- 
1.5.6.5



More information about the U-Boot mailing list