diff mbox series

[v2,1/9] cmd: bdinfo: Optionally use getopt and implement bdinfo -a

Message ID 20231007214106.15744-1-marek.vasut+renesas@mailbox.org
State Accepted
Commit b6a90ac0902ff64a5a1dabe69cf4b480ac34d69a
Delegated to: Tom Rini
Headers show
Series [v2,1/9] cmd: bdinfo: Optionally use getopt and implement bdinfo -a | expand

Commit Message

Marek Vasut Oct. 7, 2023, 9:40 p.m. UTC
Add optional support for getopt() and in case this is enabled via
GETOPT configuration option, implement support for 'bdinfo -a'.
The 'bdinfo -a' behaves exactly like bdinfo and prints 'all' the
bdinfo information. This is implemented in preparation for other
more fine-grained options.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Mario Six <mario.six@gdsys.cc>
Cc: Nikhil M Jain <n-jain1@ti.com>
Cc: Simon Glass <sjg@chromium.org>
---
V2: Add RB from Simon
---
 cmd/bdinfo.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

Comments

Marek Vasut Dec. 2, 2023, 4:33 p.m. UTC | #1
On 10/7/23 23:40, Marek Vasut wrote:
> Add optional support for getopt() and in case this is enabled via
> GETOPT configuration option, implement support for 'bdinfo -a'.
> The 'bdinfo -a' behaves exactly like bdinfo and prints 'all' the
> bdinfo information. This is implemented in preparation for other
> more fine-grained options.
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Mario Six <mario.six@gdsys.cc>
> Cc: Nikhil M Jain <n-jain1@ti.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
> V2: Add RB from Simon

I see this series marked as Superseded in patchwork , why is that so ?

Is there anything preventing this series from being applied , Tom ?
Tom Rini Dec. 9, 2023, 1:42 p.m. UTC | #2
On Sat, Dec 02, 2023 at 05:33:34PM +0100, Marek Vasut wrote:

> On 10/7/23 23:40, Marek Vasut wrote:
> > Add optional support for getopt() and in case this is enabled via
> > GETOPT configuration option, implement support for 'bdinfo -a'.
> > The 'bdinfo -a' behaves exactly like bdinfo and prints 'all' the
> > bdinfo information. This is implemented in preparation for other
> > more fine-grained options.
> > 
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> > Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> > ---
> > Cc: Bin Meng <bmeng.cn@gmail.com>
> > Cc: Mario Six <mario.six@gdsys.cc>
> > Cc: Nikhil M Jain <n-jain1@ti.com>
> > Cc: Simon Glass <sjg@chromium.org>
> > ---
> > V2: Add RB from Simon
> 
> I see this series marked as Superseded in patchwork , why is that so ?
> 
> Is there anything preventing this series from being applied , Tom ?

Dunno why I did that, sorry. Reviewing now.
Tom Rini Dec. 9, 2023, 4:14 p.m. UTC | #3
On Sat, 07 Oct 2023 23:40:58 +0200, Marek Vasut wrote:

> Add optional support for getopt() and in case this is enabled via
> GETOPT configuration option, implement support for 'bdinfo -a'.
> The 'bdinfo -a' behaves exactly like bdinfo and prints 'all' the
> bdinfo information. This is implemented in preparation for other
> more fine-grained options.
> 
> 
> [...]

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

Patch

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 1fe13ca13a0..2c0d5e9c01b 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -10,6 +10,7 @@ 
 #include <command.h>
 #include <dm.h>
 #include <env.h>
+#include <getopt.h>
 #include <lmb.h>
 #include <mapmem.h>
 #include <net.h>
@@ -133,10 +134,8 @@  static void print_serial(struct udevice *dev)
 	bdinfo_print_num_l(" clock", info.clock);
 }
 
-int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+static int bdinfo_print_all(struct bd_info *bd)
 {
-	struct bd_info *bd = gd->bd;
-
 #ifdef DEBUG
 	bdinfo_print_num_l("bd address", (ulong)bd);
 #endif
@@ -184,8 +183,30 @@  int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	return 0;
 }
 
+int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+	struct bd_info *bd = gd->bd;
+	struct getopt_state gs;
+	int opt;
+
+	if (!CONFIG_IS_ENABLED(GETOPT) || argc == 1)
+		return bdinfo_print_all(bd);
+
+	getopt_init_state(&gs);
+	while ((opt = getopt(&gs, argc, argv, "a")) > 0) {
+		switch (opt) {
+		case 'a':
+			return bdinfo_print_all(bd);
+		default:
+			return CMD_RET_USAGE;
+		}
+	}
+
+	return CMD_RET_USAGE;
+}
+
 U_BOOT_CMD(
-	bdinfo,	1,	1,	do_bdinfo,
+	bdinfo,	2,	1,	do_bdinfo,
 	"print Board Info structure",
 	""
 );