diff mbox series

[v2] fdt: Make fdt addr -q quieter

Message ID 20230321130116.4031864-1-peter.hoyes@arm.com
State Accepted
Delegated to: Simon Glass
Headers show
Series [v2] fdt: Make fdt addr -q quieter | expand

Commit Message

Peter Hoyes March 21, 2023, 1:01 p.m. UTC
From: Peter Hoyes <Peter.Hoyes@arm.com>

64597346 "fdt: Add -q option to fdt addr for distro_bootcmd" introduced
the -q option for fdt addr, which sets the current working fdt address
without printing any output.

baf41410 "fdt: Show a message when the working FDT changes" made the
utility function set_working_fdt_addr (in cmd/fdt.c) output a message
on each invocation, even if called via fdt addr -q, in which case its
output is now slightly noisier.

To fix this, split out set_working_fdt_addr into set_working_fdt_addr
plus the static function set_working_fdt_addr_quiet.
set_working_fdt_addr_quiet can be called by "quiet" fdt cmd logic and
set_working_fdt_addr is exported (as before) to other boot logic. The
latter calls the former.

Remove the assertion from the fdt addr test case when calling with the
-q argument.

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
---
 cmd/fdt.c      | 19 ++++++++++++++-----
 test/cmd/fdt.c |  1 -
 2 files changed, 14 insertions(+), 6 deletions(-)

Comments

Marek Vasut March 21, 2023, 3:19 p.m. UTC | #1
On 3/21/23 14:01, Peter Hoyes wrote:
> From: Peter Hoyes <Peter.Hoyes@arm.com>
> 
> 64597346 "fdt: Add -q option to fdt addr for distro_bootcmd" introduced
> the -q option for fdt addr, which sets the current working fdt address
> without printing any output.
> 
> baf41410 "fdt: Show a message when the working FDT changes" made the
> utility function set_working_fdt_addr (in cmd/fdt.c) output a message
> on each invocation, even if called via fdt addr -q, in which case its
> output is now slightly noisier.
> 
> To fix this, split out set_working_fdt_addr into set_working_fdt_addr
> plus the static function set_working_fdt_addr_quiet.
> set_working_fdt_addr_quiet can be called by "quiet" fdt cmd logic and
> set_working_fdt_addr is exported (as before) to other boot logic. The
> latter calls the former.
> 
> Remove the assertion from the fdt addr test case when calling with the
> -q argument.
> 
> Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>

Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

Thanks !
Simon Glass March 23, 2023, 5:54 p.m. UTC | #2
On Wed, 22 Mar 2023 at 04:19, Marek Vasut <marek.vasut@mailbox.org> wrote:
>
> On 3/21/23 14:01, Peter Hoyes wrote:
> > From: Peter Hoyes <Peter.Hoyes@arm.com>
> >
> > 64597346 "fdt: Add -q option to fdt addr for distro_bootcmd" introduced
> > the -q option for fdt addr, which sets the current working fdt address
> > without printing any output.
> >
> > baf41410 "fdt: Show a message when the working FDT changes" made the
> > utility function set_working_fdt_addr (in cmd/fdt.c) output a message
> > on each invocation, even if called via fdt addr -q, in which case its
> > output is now slightly noisier.
> >
> > To fix this, split out set_working_fdt_addr into set_working_fdt_addr
> > plus the static function set_working_fdt_addr_quiet.
> > set_working_fdt_addr_quiet can be called by "quiet" fdt cmd logic and
> > set_working_fdt_addr is exported (as before) to other boot logic. The
> > latter calls the former.
> >
> > Remove the assertion from the fdt addr test case when calling with the
> > -q argument.
> >
> > Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
>
> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass April 2, 2023, 9:33 p.m. UTC | #3
On Wed, 22 Mar 2023 at 04:19, Marek Vasut <marek.vasut@mailbox.org> wrote:
>
> On 3/21/23 14:01, Peter Hoyes wrote:
> > From: Peter Hoyes <Peter.Hoyes@arm.com>
> >
> > 64597346 "fdt: Add -q option to fdt addr for distro_bootcmd" introduced
> > the -q option for fdt addr, which sets the current working fdt address
> > without printing any output.
> >
> > baf41410 "fdt: Show a message when the working FDT changes" made the
> > utility function set_working_fdt_addr (in cmd/fdt.c) output a message
> > on each invocation, even if called via fdt addr -q, in which case its
> > output is now slightly noisier.
> >
> > To fix this, split out set_working_fdt_addr into set_working_fdt_addr
> > plus the static function set_working_fdt_addr_quiet.
> > set_working_fdt_addr_quiet can be called by "quiet" fdt cmd logic and
> > set_working_fdt_addr is exported (as before) to other boot logic. The
> > latter calls the former.
> >
> > Remove the assertion from the fdt addr test case when calling with the
> > -q argument.
> >
> > Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
>
> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm/next, thanks!
diff mbox series

Patch

diff --git a/cmd/fdt.c b/cmd/fdt.c
index f38fe909c3..f1f2ef6a12 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -36,16 +36,21 @@  static int is_printable_string(const void *data, int len);
  */
 struct fdt_header *working_fdt;
 
-void set_working_fdt_addr(ulong addr)
+static void set_working_fdt_addr_quiet(ulong addr)
 {
 	void *buf;
 
-	printf("Working FDT set to %lx\n", addr);
 	buf = map_sysmem(addr, 0);
 	working_fdt = buf;
 	env_set_hex("fdtaddr", addr);
 }
 
+void set_working_fdt_addr(ulong addr)
+{
+	printf("Working FDT set to %lx\n", addr);
+	set_working_fdt_addr_quiet(addr);
+}
+
 /*
  * Get a value from the fdt and format it to be set in the environment
  */
@@ -192,10 +197,14 @@  static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		if ((quiet && fdt_check_header(blob)) ||
 		    (!quiet && !fdt_valid(&blob)))
 			return 1;
-		if (control)
+		if (control) {
 			gd->fdt_blob = blob;
-		else
-			set_working_fdt_addr(addr);
+		} else {
+			if (quiet)
+				set_working_fdt_addr_quiet(addr);
+			else
+				set_working_fdt_addr(addr);
+		}
 
 		if (argc >= 2) {
 			int  len;
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index cdbaf8c425..85b96c614b 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -229,7 +229,6 @@  static int fdt_test_addr_resize(struct unit_test_state *uts)
 
 	/* ...quietly */
 	ut_assertok(run_commandf("fdt addr -q %08x %x", addr, sizeof(fdt) / 4));
-	ut_assert_nextline("Working FDT set to %lx", addr);
 	ut_assertok(ut_check_console_end(uts));
 
 	/* We cannot easily provoke errors in fdt_open_into(), so ignore that */