
From: Anton Staaf robotboy@chromium.org
Move the overwrite_console function call to before the search for the console devices. This lets the board specific function replace the environment variables and have that picked up by the console code.
Signed-off-by: Simon Glass sjg@chromium.org --- common/console.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/common/console.c b/common/console.c index 1177f7d..831897b 100644 --- a/common/console.c +++ b/common/console.c @@ -1,4 +1,6 @@ /* + * Copyright (c) 2009, Code Aurora Forum. All rights reserved. + * * (C) Copyright 2000 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it * @@ -622,6 +624,7 @@ int console_init_r(void) { char *stdinname, *stdoutname, *stderrname; struct stdio_dev *inputdev = NULL, *outputdev = NULL, *errdev = NULL; + int overwrite_console_retval; #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE int i; #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ @@ -636,13 +639,19 @@ int console_init_r(void) gd->jt[XF_puts] = serial_puts; gd->jt[XF_printf] = serial_printf;
- /* stdin stdout and stderr are in environment */ - /* scan for it */ + /* + * stdin stdout and stderr are in environment. + * Call OVERWRITE_CONSOLE function before scanning for stdio, stdout, + * stderr to get latest pointer after update. + * (getenv() returns NULL if var not present) + */ + overwrite_console_retval = OVERWRITE_CONSOLE; stdinname = getenv("stdin"); stdoutname = getenv("stdout"); stderrname = getenv("stderr");
- if (OVERWRITE_CONSOLE == 0) { /* if not overwritten by config switch */ + /* if not overwritten by config switch */ + if (overwrite_console_retval == 0) { inputdev = search_device(DEV_FLAGS_INPUT, stdinname); outputdev = search_device(DEV_FLAGS_OUTPUT, stdoutname); errdev = search_device(DEV_FLAGS_OUTPUT, stderrname);