[Concept,v2,13/16] console: Refactor handling of the result in on_console()
Commit Message
From: Simon Glass <sjg@chromium.org>
This function has lots of return statements in a switch statement. Move
them out so we can (later) do something else in this function.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add new patch to refactor handling of the result in on_console()
common/console.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
@@ -1040,6 +1040,7 @@ static int on_console(const char *name, const char *value, enum env_op op,
int flags)
{
int console = -1;
+ int result = 0;
/* Check for console redirection */
if (strcmp(name, "stdin") == 0)
@@ -1056,26 +1057,25 @@ static int on_console(const char *name, const char *value, enum env_op op,
switch (op) {
case env_op_create:
case env_op_overwrite:
-
if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
if (iomux_doenv(console, value))
- return 1;
+ result = 1;
} else {
/* Try assigning specified device */
if (console_assign(console, value) < 0)
- return 1;
+ result = 1;
}
-
- return 0;
-
+ break;
case env_op_delete:
if ((flags & H_FORCE) == 0)
printf("Can't delete \"%s\"\n", name);
- return 1;
-
+ result = 1;
+ break;
default:
- return 0;
+ break;
}
+
+ return result;
}
U_BOOT_ENV_CALLBACK(console, on_console);