Patchwork [U-Boot,RFC,v2,15/15] main: Add debug_bootkeys to avoid #ifdefs

login
register
mail settings
Submitter Simon Glass
Date Feb. 24, 2013, 5:26 p.m.
Message ID <1361726773-18639-16-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/222788/
State Superseded, archived
Headers show

Comments

Simon Glass - Feb. 24, 2013, 5:26 p.m.
Define a simple debug condition at the top of the file, to avoid using
lots of #ifdefs later on.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None

 common/main.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
Joe Hershberger - Feb. 24, 2013, 9:38 p.m.
Hi Simon

On Sun, Feb 24, 2013 at 11:26 AM, Simon Glass <sjg@chromium.org> wrote:
> Define a simple debug condition at the top of the file, to avoid using
> lots of #ifdefs later on.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in v2: None
>
>  common/main.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
>

Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>

Patch

diff --git a/common/main.c b/common/main.c
index 75a184c..22ed6ef 100644
--- a/common/main.c
+++ b/common/main.c
@@ -54,6 +54,11 @@  void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progre
 #define debug_parser(fmt, args...)		\
 	debug_cond(DEBUG_PARSER, fmt, ##args)
 
+#ifndef DEBUG_BOOTKEYS
+#define DEBUG_BOOTKEYS 0
+#endif
+#define debug_bootkeys(fmt, args...)		\
+	debug_cond(DEBUG_BOOTKEYS, fmt, ##args)
 
 char        console_buffer[CONFIG_SYS_CBSIZE + 1];	/* console I/O buffer	*/
 
@@ -115,11 +120,9 @@  static int abortboot_keyed(int bootdelay)
 		presskey_max = presskey_max > delaykey[i].len ?
 				    presskey_max : delaykey[i].len;
 
-#  if DEBUG_BOOTKEYS
-		printf("%s key:<%s>\n",
+		debug_bootkeys("%s key:<%s>\n",
 		       delaykey[i].retry ? "delay" : "stop",
 		       delaykey[i].str ? delaykey[i].str : "NULL");
-#  endif
 	}
 
 	/* In order to keep up with incoming data, check timeout only
@@ -144,10 +147,8 @@  static int abortboot_keyed(int bootdelay)
 			    memcmp (presskey + presskey_len - delaykey[i].len,
 				    delaykey[i].str,
 				    delaykey[i].len) == 0) {
-#  if DEBUG_BOOTKEYS
-				printf("got %skey\n",
-				       delaykey[i].retry ? "delay" : "stop");
-#  endif
+				debug_bootkeys("got %skey\n",
+					delaykey[i].retry ? "delay" : "stop");
 
 				/* don't retry auto boot? */
 				if (autoconf_boot_retry_time() &&
@@ -158,10 +159,8 @@  static int abortboot_keyed(int bootdelay)
 		}
 	} while (!abort && get_ticks() <= etime);
 
-#  if DEBUG_BOOTKEYS
 	if (!abort)
-		puts("key timeout\n");
-#  endif
+		debug_bootkeys("key timeout\n");
 
 	if (autoconf_silent_console() && abort)
 		gd->flags &= ~GD_FLG_SILENT;