main: Hide the hush/simple details inside cli.c
Move these details from main (which doesn't care which parser is used) to
cli.c where they belong.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/common/cli.c b/common/cli.c
index 9cf7ba1..4ac9b3f 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -104,3 +104,25 @@
return 0;
}
#endif
+
+void cli_loop(void)
+{
+#ifdef CONFIG_SYS_HUSH_PARSER
+ parse_file_outer();
+ /* This point is never reached */
+ for (;;);
+#else
+ cli_simple_loop();
+#endif /*CONFIG_SYS_HUSH_PARSER*/
+}
+
+void cli_init(void)
+{
+#ifdef CONFIG_SYS_HUSH_PARSER
+ u_boot_hush_start();
+#endif
+
+#if defined(CONFIG_HUSH_INIT_VAR)
+ hush_init_var();
+#endif
+}
diff --git a/common/cli_simple.c b/common/cli_simple.c
index bba586e..413c2eb 100644
--- a/common/cli_simple.c
+++ b/common/cli_simple.c
@@ -256,7 +256,7 @@
return rc ? rc : repeatable;
}
-void cli_loop(void)
+void cli_simple_loop(void)
{
static char lastcommand[CONFIG_SYS_CBSIZE] = { 0, };
diff --git a/common/main.c b/common/main.c
index b4cf289..8c846c8 100644
--- a/common/main.c
+++ b/common/main.c
@@ -10,7 +10,6 @@
#include <common.h>
#include <autoboot.h>
#include <cli.h>
-#include <cli_hush.h>
#include <malloc.h>
#include <version.h>
@@ -71,13 +70,7 @@
setenv("ver", version_string); /* set version variable */
#endif /* CONFIG_VERSION_VARIABLE */
-#ifdef CONFIG_SYS_HUSH_PARSER
- u_boot_hush_start();
-#endif
-
-#if defined(CONFIG_HUSH_INIT_VAR)
- hush_init_var();
-#endif
+ cli_init();
run_preboot_environment_command();
@@ -89,11 +82,6 @@
/*
* Main Loop for Monitor Command Processing
*/
-#ifdef CONFIG_SYS_HUSH_PARSER
- parse_file_outer();
- /* This point is never reached */
- for (;;);
-#else
+
cli_loop();
-#endif /*CONFIG_SYS_HUSH_PARSER*/
}