[PATCH 3/3] cmd: rng: Add rng list command
Weizhao Ouyang
o451686892 at gmail.com
Thu Jan 25 15:05:02 CET 2024
Add rng list command to list all probed RNG device.
Signed-off-by: Weizhao Ouyang <o451686892 at gmail.com>
---
cmd/rng.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/cmd/rng.c b/cmd/rng.c
index 52f722c7af..4818133f94 100644
--- a/cmd/rng.c
+++ b/cmd/rng.c
@@ -18,6 +18,19 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
int devnum;
struct udevice *dev;
int ret = CMD_RET_SUCCESS;
+ int idx;
+
+ if (argc == 2 && !strcmp(argv[1], "list")) {
+ uclass_foreach_dev_probe(UCLASS_RNG, dev) {
+ printf("RNG #%d - %s\n", dev->seq_, dev->name);
+ }
+
+ if (!idx) {
+ printf("*** no RNG devices available ***\n");
+ return CMD_RET_FAILURE;
+ }
+ return CMD_RET_SUCCESS;
+ }
switch (argc) {
case 1:
@@ -57,6 +70,8 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
U_BOOT_LONGHELP(rng,
+ "[list]\n"
+ " - list all the probe rng device\n"
"[dev [n]]\n"
" - print n random bytes(max 64) read from dev\n");
--
2.39.2
More information about the U-Boot
mailing list