summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-12-09 08:42:49 -0500
committerTom Rini <trini@konsulko.com>2023-12-09 08:42:49 -0500
commite54987d6af3bcf20c8270bef16c63f50698d03f4 (patch)
treed5a41fa2e77d72b06ffb7006aac73a0fac810b67 /cmd
parentd379150621a5dbe7929b43d184cb51bb8c3ec4cb (diff)
parent3ff2d796a6f251637c3ee71bb7f1e3d6964dafa2 (diff)
downloadu-boot-e54987d6af3bcf20c8270bef16c63f50698d03f4.tar.gz
u-boot-e54987d6af3bcf20c8270bef16c63f50698d03f4.tar.bz2
u-boot-e54987d6af3bcf20c8270bef16c63f50698d03f4.zip
Merge patch series "cmd: bdinfo: Optionally use getopt and implement bdinfo -a"
Clean up our bdinfo command a bit and introduce "bdinfo -a"
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bdinfo.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 1fe13ca13a..79106caeec 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,38 @@ 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, "aem")) > 0) {
+ switch (opt) {
+ case 'a':
+ return bdinfo_print_all(bd);
+ case 'e':
+ if (!IS_ENABLED(CONFIG_CMD_NET))
+ return CMD_RET_USAGE;
+ print_eth();
+ return CMD_RET_SUCCESS;
+ case 'm':
+ print_bi_dram(bd);
+ return CMD_RET_SUCCESS;
+ 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",
""
);