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:
parent
9244645f92
commit
8676ae36ae
5 changed files with 45 additions and 37 deletions
24
cmd/adc.c
24
cmd/adc.c
|
@ -12,23 +12,19 @@ static int do_adc_list(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int ret;
|
int ret, err;
|
||||||
|
|
||||||
ret = uclass_first_device_err(UCLASS_ADC, &dev);
|
ret = err = uclass_first_device_check(UCLASS_ADC, &dev);
|
||||||
if (ret) {
|
|
||||||
printf("No available ADC device\n");
|
while (dev) {
|
||||||
return CMD_RET_FAILURE;
|
printf("- %s status: %i\n", dev->name, ret);
|
||||||
|
|
||||||
|
ret = uclass_next_device_check(&dev);
|
||||||
|
if (ret)
|
||||||
|
err = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
return err ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
|
||||||
printf("- %s\n", dev->name);
|
|
||||||
|
|
||||||
ret = uclass_next_device(&dev);
|
|
||||||
if (ret)
|
|
||||||
return CMD_RET_FAILURE;
|
|
||||||
} while (dev);
|
|
||||||
|
|
||||||
return CMD_RET_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
|
15
cmd/demo.c
15
cmd/demo.c
|
@ -64,20 +64,23 @@ static int do_demo_light(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
int do_demo_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
int do_demo_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int i, ret;
|
int i, ret, err = 0;
|
||||||
|
|
||||||
puts("Demo uclass entries:\n");
|
puts("Demo uclass entries:\n");
|
||||||
|
|
||||||
for (i = 0, ret = uclass_first_device(UCLASS_DEMO, &dev);
|
for (i = 0, ret = uclass_first_device_check(UCLASS_DEMO, &dev);
|
||||||
dev;
|
dev;
|
||||||
ret = uclass_next_device(&dev)) {
|
ret = uclass_next_device_check(&dev)) {
|
||||||
printf("entry %d - instance %08x, ops %08x, plat %08x\n",
|
printf("entry %d - instance %08x, ops %08x, plat %08x, status %i\n",
|
||||||
i++, (uint)map_to_sysmem(dev),
|
i++, (uint)map_to_sysmem(dev),
|
||||||
(uint)map_to_sysmem(dev->driver->ops),
|
(uint)map_to_sysmem(dev->driver->ops),
|
||||||
(uint)map_to_sysmem(dev_get_plat(dev)));
|
(uint)map_to_sysmem(dev_get_plat(dev)),
|
||||||
|
ret);
|
||||||
|
if (ret)
|
||||||
|
err = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_process_error(cmdtp, ret);
|
return cmd_process_error(cmdtp, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_tbl demo_commands[] = {
|
static struct cmd_tbl demo_commands[] = {
|
||||||
|
|
15
cmd/gpio.c
15
cmd/gpio.c
|
@ -77,17 +77,24 @@ static int do_gpio_status(bool all, const char *gpio_name)
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int banklen;
|
int banklen;
|
||||||
int flags;
|
int flags;
|
||||||
int ret;
|
int ret, err = 0;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (gpio_name && !*gpio_name)
|
if (gpio_name && !*gpio_name)
|
||||||
gpio_name = NULL;
|
gpio_name = NULL;
|
||||||
for (ret = uclass_first_device(UCLASS_GPIO, &dev);
|
for (ret = uclass_first_device_check(UCLASS_GPIO, &dev);
|
||||||
dev;
|
dev;
|
||||||
ret = uclass_next_device(&dev)) {
|
ret = uclass_next_device_check(&dev)) {
|
||||||
const char *bank_name;
|
const char *bank_name;
|
||||||
int num_bits;
|
int num_bits;
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
printf("GPIO device %s probe error %i\n",
|
||||||
|
dev->name, ret);
|
||||||
|
err = ret;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
flags |= FLAG_SHOW_BANK;
|
flags |= FLAG_SHOW_BANK;
|
||||||
if (all)
|
if (all)
|
||||||
flags |= FLAG_SHOW_ALL;
|
flags |= FLAG_SHOW_ALL;
|
||||||
|
@ -120,7 +127,7 @@ static int do_gpio_status(bool all, const char *gpio_name)
|
||||||
flags |= FLAG_SHOW_NEWLINE;
|
flags |= FLAG_SHOW_NEWLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return err;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
15
cmd/pmic.c
15
cmd/pmic.c
|
@ -51,25 +51,26 @@ static int do_list(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int ret;
|
int ret, err = 0;
|
||||||
|
|
||||||
printf("| %-*.*s| %-*.*s| %s @ %s\n",
|
printf("| %-*.*s| %-*.*s| %s @ %s\n",
|
||||||
LIMIT_DEV, LIMIT_DEV, "Name",
|
LIMIT_DEV, LIMIT_DEV, "Name",
|
||||||
LIMIT_PARENT, LIMIT_PARENT, "Parent name",
|
LIMIT_PARENT, LIMIT_PARENT, "Parent name",
|
||||||
"Parent uclass", "seq");
|
"Parent uclass", "seq");
|
||||||
|
|
||||||
for (ret = uclass_first_device(UCLASS_PMIC, &dev); dev;
|
for (ret = uclass_first_device_check(UCLASS_PMIC, &dev); dev;
|
||||||
ret = uclass_next_device(&dev)) {
|
ret = uclass_next_device_check(&dev)) {
|
||||||
if (ret)
|
if (ret)
|
||||||
continue;
|
err = ret;
|
||||||
|
|
||||||
printf("| %-*.*s| %-*.*s| %s @ %d\n",
|
printf("| %-*.*s| %-*.*s| %s @ %d | status: %i\n",
|
||||||
LIMIT_DEV, LIMIT_DEV, dev->name,
|
LIMIT_DEV, LIMIT_DEV, dev->name,
|
||||||
LIMIT_PARENT, LIMIT_PARENT, dev->parent->name,
|
LIMIT_PARENT, LIMIT_PARENT, dev->parent->name,
|
||||||
dev_get_uclass_name(dev->parent), dev_seq(dev->parent));
|
dev_get_uclass_name(dev->parent), dev_seq(dev->parent),
|
||||||
|
ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret)
|
if (err)
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
|
|
||||||
return CMD_RET_SUCCESS;
|
return CMD_RET_SUCCESS;
|
||||||
|
|
|
@ -205,7 +205,7 @@ static void do_status_detail(struct udevice *dev,
|
||||||
constraint(" * mode id:", mode, mode_name);
|
constraint(" * mode id:", mode, mode_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_status_line(struct udevice *dev)
|
static void do_status_line(struct udevice *dev, int status)
|
||||||
{
|
{
|
||||||
struct dm_regulator_uclass_plat *pdata;
|
struct dm_regulator_uclass_plat *pdata;
|
||||||
int current, value, mode;
|
int current, value, mode;
|
||||||
|
@ -231,6 +231,7 @@ static void do_status_line(struct udevice *dev)
|
||||||
printf("%-10s", mode_name);
|
printf("%-10s", mode_name);
|
||||||
else
|
else
|
||||||
printf("%-10s", "-");
|
printf("%-10s", "-");
|
||||||
|
printf(" %i", status);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,11 +251,11 @@ static int do_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show all of them in a list, probing them as needed */
|
/* Show all of them in a list, probing them as needed */
|
||||||
printf("%-20s %-10s %10s %10s %-10s\n", "Name", "Enabled", "uV", "mA",
|
printf("%-20s %-10s %10s %10s %-10s %s\n", "Name", "Enabled", "uV", "mA",
|
||||||
"Mode");
|
"Mode", "Status");
|
||||||
for (ret = uclass_first_device(UCLASS_REGULATOR, &dev); dev;
|
for (ret = uclass_first_device_check(UCLASS_REGULATOR, &dev); dev;
|
||||||
ret = uclass_next_device(&dev))
|
ret = uclass_next_device_check(&dev))
|
||||||
do_status_line(dev);
|
do_status_line(dev, ret);
|
||||||
|
|
||||||
return CMD_RET_SUCCESS;
|
return CMD_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue