Skip to contentSkip to conversation

common/console.c: ensure GD_FLG_SILENT is set or cleared

RFC PATCH In review Chris Packham 3 participants 3 messages Sep 23, 2016 – Oct 8, 2016

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 common/console.c: ensure GD_FLG_SILENT is set or cleared

When CONFIG_SILENT_CONSOLE is defined and the default environment has silent=1 it is not possible for a user to make the console un-silent if the environment is not available when console_init_f() is called (for example because the environment is in SPI).

Add a new helper function console_update_silent() and call it from both console_init_f() and console_init_r().

---

 common/console.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
common/console.c +13 -4
index 12293f383624..c7f32434310e 100644
@@ -687,15 +687,22 @@ int console_assign(int file, const char *devname)
 	return -1;
 }
 
-/* Called before relocation - use serial functions */
-int console_init_f(void)
+static void console_update_silent(void)
 {
-	gd->have_console = 1;
-
 #ifdef CONFIG_SILENT_CONSOLE
 	if (getenv("silent") != NULL)
 		gd->flags |= GD_FLG_SILENT;
+	else
+		gd->flags &= ~GD_FLG_SILENT;
 #endif
+}
+
+/* Called before relocation - use serial functions */
+int console_init_f(void)
+{
+	gd->have_console = 1;
+
+	console_update_silent();
 
 	print_pre_console_buffer(PRE_CONSOLE_FLUSHPOINT1_SERIAL);
 
@@ -831,6 +838,8 @@ int console_init_r(void)
 	struct list_head *pos;
 	struct stdio_dev *dev;
 
+	console_update_silent();
+
 #ifdef CONFIG_SPLASH_SCREEN
 	/*
 	 * suppress all output if splash screen is enabled and we have
Signature · 1 line
2.9.2.518.ged577c6.dirty
#1 lore raw

RFC PATCH 1/1 common/console.c: ensure GD_FLG_SILENT is set or cleared

Hi Chris,

Quoted 5 lines · Chris Packham

When CONFIG_SILENT_CONSOLE is defined and the default environment has silent=1 it is not possible for a user to make the console un-silent if the environment is not available when console_init_f() is called (for example because the environment is in SPI).

Quoted 8 lines

Add a new helper function console_update_silent() and call it from both console_init_f() and console_init_r().

---

 common/console.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

I'm not completely sure that this is the intended behaviour, but it seems reasonable. I'd really like to see docs in the README (or elsewhere) about the effect of the 'silent' env variable...

- Simon

#2 lore raw
In reply to Chris Packham
Quoted 10 lines · Chris Packham

When CONFIG_SILENT_CONSOLE is defined and the default environment has silent=1 it is not possible for a user to make the console un-silent if the environment is not available when console_init_f() is called (for example because the environment is in SPI).

Add a new helper function console_update_silent() and call it from both console_init_f() and console_init_r().

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/8deb8f95/attachment.sig>