[PATCH v4 08/21] bootstd: Fix listing boot devices

Michal Suchanek msuchanek at suse.de
Sun Sep 25 10:28:01 CEST 2022


bootdev_list() uses uclass_*_device_err() to iterate devices.
However, the only value _err adds is returning an error when the device
pointer is null, and that's checked anyway.

Also there is some intent to report errors, and that's what
uclass_*_device_check() is for, use it.

Also print the symbolic error.

Signed-off-by: Michal Suchanek <msuchanek at suse.de>
---
 boot/bootdev-uclass.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 13ac69eb39..e7115c5750 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -13,6 +13,7 @@
 #include <bootmeth.h>
 #include <bootstd.h>
 #include <env.h>
+#include <errno.h>
 #include <fs.h>
 #include <log.h>
 #include <malloc.h>
@@ -195,16 +196,16 @@ void bootdev_list(bool probe)
 	printf("Seq  Probed  Status  Uclass    Name\n");
 	printf("---  ------  ------  --------  ------------------\n");
 	if (probe)
-		ret = uclass_first_device_err(UCLASS_BOOTDEV, &dev);
+		ret = uclass_first_device_check(UCLASS_BOOTDEV, &dev);
 	else
 		ret = uclass_find_first_device(UCLASS_BOOTDEV, &dev);
 	for (i = 0; dev; i++) {
 		printf("%3x   [ %c ]  %6s  %-9.9s %s\n", dev_seq(dev),
 		       device_active(dev) ? '+' : ' ',
-		       ret ? simple_itoa(ret) : "OK",
+		       ret ? errno_str(ret) : "OK",
 		       dev_get_uclass_name(dev_get_parent(dev)), dev->name);
 		if (probe)
-			ret = uclass_next_device_err(&dev);
+			ret = uclass_next_device_check(&dev);
 		else
 			ret = uclass_find_next_device(&dev);
 	}
-- 
2.37.3



More information about the U-Boot mailing list