cmd: List all uclass devices regardless of probe error
There are a few commands that iterate uclass with
uclass_first_device/uclass_next_device or the _err variant.
Use the _check class iterator variant to get devices that fail to probe
as well, and print the status.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/cmd/adc.c b/cmd/adc.c
index 1c5d3e1..a739d9e 100644
--- a/cmd/adc.c
+++ b/cmd/adc.c
@@ -12,23 +12,19 @@
char *const argv[])
{
struct udevice *dev;
- int ret;
+ int ret, err;
- ret = uclass_first_device_err(UCLASS_ADC, &dev);
- if (ret) {
- printf("No available ADC device\n");
- return CMD_RET_FAILURE;
+ ret = err = uclass_first_device_check(UCLASS_ADC, &dev);
+
+ while (dev) {
+ printf("- %s status: %i\n", dev->name, ret);
+
+ ret = uclass_next_device_check(&dev);
+ if (ret)
+ err = ret;
}
- do {
- printf("- %s\n", dev->name);
-
- ret = uclass_next_device(&dev);
- if (ret)
- return CMD_RET_FAILURE;
- } while (dev);
-
- return CMD_RET_SUCCESS;
+ return err ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
}
static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int argc,