Patchwork [U-Boot,06/12] env: Make the "silent" env var take effect immediately

login
register
mail settings
Submitter Joe Hershberger
Date Aug. 17, 2012, 8:49 p.m.
Message ID <1345236586-19076-7-git-send-email-joe.hershberger@ni.com>
Download mbox | patch
Permalink /patch/178377/
State Changes Requested
Delegated to: Tom Rini
Headers show

Comments

Joe Hershberger - Aug. 17, 2012, 8:49 p.m.
The silent variable now updates the global data flag anytime it is
changed as well as after the env relocation (in case its value is
different from the default env in such cases as NAND env)

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 common/cmd_nvedit.c | 16 ++++++++++++++++
 common/env_common.c |  8 ++++++++
 doc/README.silent   | 14 ++++++++++----
 3 files changed, 34 insertions(+), 4 deletions(-)
Mike Frysinger - Aug. 23, 2012, 3:35 a.m.
On Friday 17 August 2012 16:49:40 Joe Hershberger wrote:
> --- a/common/cmd_nvedit.c
> +++ b/common/cmd_nvedit.c
>
> +#if defined(CONFIG_SILENT_CONSOLE) && \
> +	defined(CONFIG_SILENT_CONSOLE_UPDATE_ON_SET)

i wonder if the CONFIG_SILENT_CONSOLE check is needed.  setting the latter 
without the former doesn't make sense.

> +- CONFIG_SILENT_CONSOLE_UPDATE_ON_SET
> +	When the "silent" variable is changed with env set, the change
> +	will take effect immediately

should end in a "."
-mike

Patch

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index fd05e72..bd52fa4 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -303,9 +303,25 @@  int _do_env_set(int flag, int argc, char * const argv[])
 	/* Delete only ? */
 	if (argc < 3 || argv[2] == NULL) {
 		int rc = hdelete_r(name, &env_htab);
+
+#if defined(CONFIG_SILENT_CONSOLE) && \
+	defined(CONFIG_SILENT_CONSOLE_UPDATE_ON_SET)
+		if (strcmp(name, "silent") == 0) {
+			/* silent is deleted */
+			gd->flags &= ~GD_FLG_SILENT;
+		}
+#endif
 		return !rc;
 	}
 
+#if defined(CONFIG_SILENT_CONSOLE) && \
+	defined(CONFIG_SILENT_CONSOLE_UPDATE_ON_SET)
+	if (strcmp(name, "silent") == 0) {
+		/* silent is added */
+		gd->flags |= GD_FLG_SILENT;
+	}
+#endif
+
 	/*
 	 * Insert / replace new value
 	 */
diff --git a/common/env_common.c b/common/env_common.c
index d9e990d..0c7e845 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -245,6 +245,14 @@  void env_relocate(void)
 	} else {
 		env_relocate_spec();
 	}
+
+#if defined(CONFIG_SILENT_CONSOLE) && \
+	defined(CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC)
+	if (getenv("silent") != NULL)
+		gd->flags |= GD_FLG_SILENT;
+	else
+		gd->flags &= ~GD_FLG_SILENT;
+#endif
 }
 
 #ifdef CONFIG_AUTO_COMPLETE
diff --git a/doc/README.silent b/doc/README.silent
index a26e3df..a04961f 100644
--- a/doc/README.silent
+++ b/doc/README.silent
@@ -1,9 +1,15 @@ 
 The config option CONFIG_SILENT_CONSOLE can be used to quiet messages
 on the console.  If the option has been enabled, the output can be
-silenced by setting the environment variable "silent".  The variable
-is latched into the global data at an early stage in the boot process
-so deleting it with "setenv" will not take effect until the system is
-restarted.
+silenced by setting the environment variable "silent".
+
+- CONFIG_SILENT_CONSOLE_UPDATE_ON_SET
+	When the "silent" variable is changed with env set, the change
+	will take effect immediately
+
+- CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC
+	Some environments are not available until relocation (e.g. NAND)
+	so this will make the value in the flash env take effect at
+	relocation.
 
 The following actions are taken if "silent" is set at boot time: