
From: Simon Glass <sjg@chromium.org> Move the environment callbacks lower so that we can call functions elsewhere in common/console.c Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v2: - Add new patch to move environment handling lower in the file common/console.c | 130 +++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/common/console.c b/common/console.c index c6dfed6e201..51f646d9fd4 100644 --- a/common/console.c +++ b/common/console.c @@ -29,71 +29,6 @@ DECLARE_GLOBAL_DATA_PTR; #define CSI "\x1b[" -static int on_console(const char *name, const char *value, enum env_op op, - int flags) -{ - int console = -1; - - /* Check for console redirection */ - if (strcmp(name, "stdin") == 0) - console = stdin; - else if (strcmp(name, "stdout") == 0) - console = stdout; - else if (strcmp(name, "stderr") == 0) - console = stderr; - - /* if not actually setting a console variable, we don't care */ - if (console == -1 || (gd->flags & GD_FLG_DEVINIT) == 0) - return 0; - - switch (op) { - case env_op_create: - case env_op_overwrite: - - if (CONFIG_IS_ENABLED(CONSOLE_MUX)) { - if (iomux_doenv(console, value)) - return 1; - } else { - /* Try assigning specified device */ - if (console_assign(console, value) < 0) - return 1; - } - - return 0; - - case env_op_delete: - if ((flags & H_FORCE) == 0) - printf("Can't delete \"%s\"\n", name); - return 1; - - default: - return 0; - } -} -U_BOOT_ENV_CALLBACK(console, on_console); - -#ifdef CONFIG_SILENT_CONSOLE -static int on_silent(const char *name, const char *value, enum env_op op, - int flags) -{ - if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_SET)) - if (flags & H_INTERACTIVE) - return 0; - - if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_RELOC)) - if ((flags & H_INTERACTIVE) == 0) - return 0; - - if (value != NULL) - gd->flags |= GD_FLG_SILENT; - else - gd->flags &= ~GD_FLG_SILENT; - - return 0; -} -U_BOOT_ENV_CALLBACK(silent, on_silent); -#endif - #ifdef CONFIG_CONSOLE_RECORD /* helper function: access to gd->console_out and gd->console_in */ static void console_record_putc(const char c) @@ -1101,6 +1036,71 @@ static void stdio_print_current_devices(void) printf("%s\n", stderrname); } +static int on_console(const char *name, const char *value, enum env_op op, + int flags) +{ + int console = -1; + + /* Check for console redirection */ + if (strcmp(name, "stdin") == 0) + console = stdin; + else if (strcmp(name, "stdout") == 0) + console = stdout; + else if (strcmp(name, "stderr") == 0) + console = stderr; + + /* if not actually setting a console variable, we don't care */ + if (console == -1 || (gd->flags & GD_FLG_DEVINIT) == 0) + return 0; + + switch (op) { + case env_op_create: + case env_op_overwrite: + + if (CONFIG_IS_ENABLED(CONSOLE_MUX)) { + if (iomux_doenv(console, value)) + return 1; + } else { + /* Try assigning specified device */ + if (console_assign(console, value) < 0) + return 1; + } + + return 0; + + case env_op_delete: + if ((flags & H_FORCE) == 0) + printf("Can't delete \"%s\"\n", name); + return 1; + + default: + return 0; + } +} +U_BOOT_ENV_CALLBACK(console, on_console); + +#ifdef CONFIG_SILENT_CONSOLE +static int on_silent(const char *name, const char *value, enum env_op op, + int flags) +{ + if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_SET)) + if (flags & H_INTERACTIVE) + return 0; + + if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_RELOC)) + if ((flags & H_INTERACTIVE) == 0) + return 0; + + if (value) + gd->flags |= GD_FLG_SILENT; + else + gd->flags &= ~GD_FLG_SILENT; + + return 0; +} +U_BOOT_ENV_CALLBACK(silent, on_silent); +#endif + #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) /* Called after the relocation - use desired console functions */ int console_init_r(void) -- 2.43.0