Patchwork [U-Boot,13/16] New config variable CONFIG_PREMONITOR

login
register
mail settings
Submitter Pali Rohár
Date Dec. 17, 2011, 5:03 p.m.
Message ID <1324141398-14859-13-git-send-email-pali.rohar@gmail.com>
Download mbox | patch
Permalink /patch/132014/
State Changes Requested
Headers show

Comments

Pali Rohár - Dec. 17, 2011, 5:03 p.m.
* if defined run env "premonitor" before Main Loop for Monitor Command Processing

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 common/env_common.c |    3 +++
 common/main.c       |   10 ++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
Mike Frysinger - Dec. 18, 2011, 7:05 p.m.
On Saturday 17 December 2011 12:03:15 Pali Rohár wrote:
> --- a/common/env_common.c
> +++ b/common/env_common.c
>
> +#ifdef	CONFIG_PREMONITOR
> +	"premonitor="	CONFIG_PREMONITOR		"\0"
> +#endif
>
> --- a/common/main.c
> +++ b/common/main.c
> 
> +#ifdef CONFIG_PREMONITOR
> +	if ((s = getenv ("premonitor")) != NULL) {

i don't these should be the same define.  one is to control the default env var 
value only.  i would just drop the check in main.c.

> +# ifndef CONFIG_SYS_HUSH_PARSER
> +		run_command (s, 0);

no space before the "("
-mike
Pali Rohár - Dec. 18, 2011, 7:37 p.m.
On Sunday 18 December 2011 14:05:17 Mike Frysinger wrote:
> On Saturday 17 December 2011 12:03:15 Pali Rohár wrote:
> > --- a/common/env_common.c
> > +++ b/common/env_common.c
> > 
> > +#ifdef	CONFIG_PREMONITOR
> > +	"premonitor="	CONFIG_PREMONITOR		"\0"
> > +#endif
> > 
> > --- a/common/main.c
> > +++ b/common/main.c
> > 
> > +#ifdef CONFIG_PREMONITOR
> > +	if ((s = getenv ("premonitor")) != NULL) {
> 
> i don't these should be the same define.  one is to control the default env
> var value only.  i would just drop the check in main.c.
> 
> > +# ifndef CONFIG_SYS_HUSH_PARSER
> > +		run_command (s, 0);
> 
> no space before the "("
> -mike

So do you think that I should delete changes in env_common.c and add to main.c 
only this code?

+#ifdef CONFIG_PREMONITOR
+	run_command2(CONFIG_PREMONITOR, 0);
+#endif
Mike Frysinger - Dec. 18, 2011, 8:08 p.m.
On Sunday 18 December 2011 14:37:12 Pali Rohár wrote:
> On Sunday 18 December 2011 14:05:17 Mike Frysinger wrote:
> > On Saturday 17 December 2011 12:03:15 Pali Rohár wrote:
> > > --- a/common/env_common.c
> > > +++ b/common/env_common.c
> > > 
> > > +#ifdef	CONFIG_PREMONITOR
> > > +	"premonitor="	CONFIG_PREMONITOR		"\0"
> > > +#endif
> > > 
> > > --- a/common/main.c
> > > +++ b/common/main.c
> > > 
> > > +#ifdef CONFIG_PREMONITOR
> > > +	if ((s = getenv ("premonitor")) != NULL) {
> > 
> > i don't these should be the same define.  one is to control the default
> > env var value only.  i would just drop the check in main.c.
> 
> So do you think that I should delete changes in env_common.c and add to
> main.c only this code?

i mean keep the code in env_common.c, and delete the "#ifdef 
CONFIG_PREMONITOR" line from main.c
-mike
Pali Rohár - Dec. 18, 2011, 8:14 p.m.
On Sunday 18 December 2011 15:08:30 Mike Frysinger wrote:
> On Sunday 18 December 2011 14:37:12 Pali Rohár wrote:
> > On Sunday 18 December 2011 14:05:17 Mike Frysinger wrote:
> > > On Saturday 17 December 2011 12:03:15 Pali Rohár wrote:
> > > > --- a/common/env_common.c
> > > > +++ b/common/env_common.c
> > > > 
> > > > +#ifdef	CONFIG_PREMONITOR
> > > > +	"premonitor="	CONFIG_PREMONITOR		"\0"
> > > > +#endif
> > > > 
> > > > --- a/common/main.c
> > > > +++ b/common/main.c
> > > > 
> > > > +#ifdef CONFIG_PREMONITOR
> > > > +	if ((s = getenv ("premonitor")) != NULL) {
> > > 
> > > i don't these should be the same define.  one is to control the
> > > default
> > > env var value only.  i would just drop the check in main.c.
> > 
> > So do you think that I should delete changes in env_common.c and add to
> > main.c only this code?
> 
> i mean keep the code in env_common.c, and delete the "#ifdef
> CONFIG_PREMONITOR" line from main.c
> -mike

Ok.

Patch

diff --git a/common/env_common.c b/common/env_common.c
index 8a71096..1ef8ecc 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -92,6 +92,9 @@  const uchar default_environment[] = {
 #ifdef	CONFIG_PREBOOT
 	"preboot="	CONFIG_PREBOOT			"\0"
 #endif
+#ifdef	CONFIG_PREMONITOR
+	"premonitor="	CONFIG_PREMONITOR		"\0"
+#endif
 #ifdef	CONFIG_ROOTPATH
 	"rootpath="	CONFIG_ROOTPATH			"\0"
 #endif
diff --git a/common/main.c b/common/main.c
index fc80317..3dd9fc7 100644
--- a/common/main.c
+++ b/common/main.c
@@ -425,6 +425,16 @@  void main_loop (void)
 	}
 #endif
 
+#ifdef CONFIG_PREMONITOR
+	if ((s = getenv ("premonitor")) != NULL) {
+# ifndef CONFIG_SYS_HUSH_PARSER
+		run_command (s, 0);
+# else
+		parse_string_outer(s, FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP);
+# endif
+	}
+#endif /* CONFIG_PREMONITOR */
+
 	/*
 	 * Main Loop for Monitor Command Processing
 	 */