public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] setenv: do console redirection even if previously unset
@ 2009-10-08 12:29 Alessandro Rubini
  2009-10-18 21:07 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Alessandro Rubini @ 2009-10-08 12:29 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

If "stdout" is not previously set, doing "setenv stdout lcd" had no
effect, since console redirection only worked if the environment
variable was already set; the second time you run setenv it worked.
Most default environments lack stdin/out/err definitions, so I'm sure
I'm not alone with this problem.

This patch simply moves a block of code out of a conditional, to do
the same work even if the variable was previously unset.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
 common/cmd_nvedit.c |   62 +++++++++++++++++++++++++-------------------------
 1 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 2186205..9f8d531 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -202,6 +202,37 @@ int _do_setenv (int flag, int argc, char *argv[])
 			break;
 	}
 
+	/* Check for console redirection */
+	if (strcmp(name,"stdin") == 0) {
+		console = stdin;
+	} else if (strcmp(name,"stdout") == 0) {
+		console = stdout;
+	} else if (strcmp(name,"stderr") == 0) {
+		console = stderr;
+	}
+
+	if (console != -1) {
+		if (argc < 3) {		/* Cannot delete it! */
+			printf("Can't delete \"%s\"\n", name);
+			return 1;
+		}
+
+#ifdef CONFIG_CONSOLE_MUX
+		i = iomux_doenv(console, argv[2]);
+		if (i)
+			return i;
+#else
+		/* Try assigning specified device */
+		if (console_assign (console, argv[2]) < 0)
+			return 1;
+
+#ifdef CONFIG_SERIAL_MULTI
+		if (serial_assign (argv[2]) < 0)
+			return 1;
+#endif
+#endif /* CONFIG_CONSOLE_MUX */
+	}
+
 	/*
 	 * Delete any existing definition
 	 */
@@ -229,37 +260,6 @@ int _do_setenv (int flag, int argc, char *argv[])
 		}
 #endif
 
-		/* Check for console redirection */
-		if (strcmp(name,"stdin") == 0) {
-			console = stdin;
-		} else if (strcmp(name,"stdout") == 0) {
-			console = stdout;
-		} else if (strcmp(name,"stderr") == 0) {
-			console = stderr;
-		}
-
-		if (console != -1) {
-			if (argc < 3) {		/* Cannot delete it! */
-				printf("Can't delete \"%s\"\n", name);
-				return 1;
-			}
-
-#ifdef CONFIG_CONSOLE_MUX
-			i = iomux_doenv(console, argv[2]);
-			if (i)
-				return i;
-#else
-			/* Try assigning specified device */
-			if (console_assign (console, argv[2]) < 0)
-				return 1;
-
-#ifdef CONFIG_SERIAL_MULTI
-			if (serial_assign (argv[2]) < 0)
-				return 1;
-#endif
-#endif /* CONFIG_CONSOLE_MUX */
-		}
-
 		/*
 		 * Switch to new baudrate if new baudrate is supported
 		 */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] setenv: do console redirection even if previously unset
  2009-10-08 12:29 [U-Boot] [PATCH] setenv: do console redirection even if previously unset Alessandro Rubini
@ 2009-10-18 21:07 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2009-10-18 21:07 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <20091008122914.GA4674@mail.gnudd.com> you wrote:
> From: Alessandro Rubini <rubini@unipv.it>
> 
> If "stdout" is not previously set, doing "setenv stdout lcd" had no
> effect, since console redirection only worked if the environment
> variable was already set; the second time you run setenv it worked.
> Most default environments lack stdin/out/err definitions, so I'm sure
> I'm not alone with this problem.
> 
> This patch simply moves a block of code out of a conditional, to do
> the same work even if the variable was previously unset.
> 
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
> ---
>  common/cmd_nvedit.c |   62 +++++++++++++++++++++++++-------------------------
>  1 files changed, 31 insertions(+), 31 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Our business is run on trust.  We trust you will pay in advance.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-18 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-08 12:29 [U-Boot] [PATCH] setenv: do console redirection even if previously unset Alessandro Rubini
2009-10-18 21:07 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox