From ac5632fc504f4e66b61131047326e78c16210d5c Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 17 Apr 2020 02:24:04 +0800 Subject: [PATCH] nshlib: Move BOARDIOC_FINALINIT into nsh_initscript 1.Avoid the code duplication 2.Call BOARDIOC_FINALINIT onnce and only once 3.Ensure BOARDIOC_FINALINIT get called in all case Signed-off-by: Xiang Xiao --- nshlib/nsh_altconsole.c | 6 ------ nshlib/nsh_consolemain.c | 6 ------ nshlib/nsh_script.c | 6 ++++++ nshlib/nsh_usbconsole.c | 6 ------ 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/nshlib/nsh_altconsole.c b/nshlib/nsh_altconsole.c index dd574becb..ed2fe82c2 100644 --- a/nshlib/nsh_altconsole.c +++ b/nshlib/nsh_altconsole.c @@ -292,12 +292,6 @@ int nsh_consolemain(int argc, char *argv[]) netinit_bringup(); #endif -#if defined(CONFIG_NSH_ARCHINIT) && defined(CONFIG_BOARDCTL_FINALINIT) - /* Perform architecture-specific final-initialization (if configured) */ - - boardctl(BOARDIOC_FINALINIT, 0); -#endif - /* First map stderr and stdout to alternative devices */ ret = nsh_clone_console(pstate); diff --git a/nshlib/nsh_consolemain.c b/nshlib/nsh_consolemain.c index 61aabf3ae..5ff9f0ed0 100644 --- a/nshlib/nsh_consolemain.c +++ b/nshlib/nsh_consolemain.c @@ -110,12 +110,6 @@ int nsh_consolemain(int argc, char *argv[]) netinit_bringup(); #endif -#if defined(CONFIG_NSH_ARCHINIT) && defined(CONFIG_BOARDCTL_FINALINIT) - /* Perform architecture-specific final-initialization (if configured) */ - - boardctl(BOARDIOC_FINALINIT, 0); -#endif - /* Execute the session */ ret = nsh_session(pstate); diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c index a29994ebf..cf77ef964 100644 --- a/nshlib/nsh_script.c +++ b/nshlib/nsh_script.c @@ -190,6 +190,12 @@ int nsh_initscript(FAR struct nsh_vtbl_s *vtbl) if (!already) { ret = nsh_script(vtbl, "init", NSH_INITPATH); + +#if defined(CONFIG_NSH_ARCHINIT) && defined(CONFIG_BOARDCTL_FINALINIT) + /* Perform architecture-specific final-initialization (if configured) */ + + boardctl(BOARDIOC_FINALINIT, 0); +#endif } return ret; diff --git a/nshlib/nsh_usbconsole.c b/nshlib/nsh_usbconsole.c index 11c160219..60a881599 100644 --- a/nshlib/nsh_usbconsole.c +++ b/nshlib/nsh_usbconsole.c @@ -325,12 +325,6 @@ int nsh_consolemain(int argc, char *argv[]) netinit_bringup(); #endif -#if defined(CONFIG_NSH_ARCHINIT) && defined(CONFIG_BOARDCTL_FINALINIT) - /* Perform architecture-specific final-initialization (if configured) */ - - boardctl(BOARDIOC_FINALINIT, 0); -#endif - /* Now loop, executing creating a session for each USB connection */ for (;;)