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>
This commit is contained in:
Michal Suchanek
2022-10-12 21:57:58 +02:00
committed by Simon Glass
parent 9244645f92
commit 8676ae36ae
5 changed files with 45 additions and 37 deletions

View File

@@ -12,23 +12,19 @@ static int do_adc_list(struct cmd_tbl *cmdtp, int flag, int argc,
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,