Skip to content

Commit 8676ae3

Browse files
hramrachsjg20
authored andcommitted
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 <[email protected]> Reviewed-by: Simon Glass <[email protected]>
1 parent 9244645 commit 8676ae3

File tree

5 files changed

+43
-35
lines changed

5 files changed

+43
-35
lines changed

cmd/adc.c

+8-12
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,19 @@ static int do_adc_list(struct cmd_tbl *cmdtp, int flag, int argc,
1212
char *const argv[])
1313
{
1414
struct udevice *dev;
15-
int ret;
15+
int ret, err;
1616

17-
ret = uclass_first_device_err(UCLASS_ADC, &dev);
18-
if (ret) {
19-
printf("No available ADC device\n");
20-
return CMD_RET_FAILURE;
21-
}
17+
ret = err = uclass_first_device_check(UCLASS_ADC, &dev);
2218

23-
do {
24-
printf("- %s\n", dev->name);
19+
while (dev) {
20+
printf("- %s status: %i\n", dev->name, ret);
2521

26-
ret = uclass_next_device(&dev);
22+
ret = uclass_next_device_check(&dev);
2723
if (ret)
28-
return CMD_RET_FAILURE;
29-
} while (dev);
24+
err = ret;
25+
}
3026

31-
return CMD_RET_SUCCESS;
27+
return err ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
3228
}
3329

3430
static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int argc,

cmd/demo.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,23 @@ static int do_demo_light(struct cmd_tbl *cmdtp, int flag, int argc,
6464
int do_demo_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
6565
{
6666
struct udevice *dev;
67-
int i, ret;
67+
int i, ret, err = 0;
6868

6969
puts("Demo uclass entries:\n");
7070

71-
for (i = 0, ret = uclass_first_device(UCLASS_DEMO, &dev);
71+
for (i = 0, ret = uclass_first_device_check(UCLASS_DEMO, &dev);
7272
dev;
73-
ret = uclass_next_device(&dev)) {
74-
printf("entry %d - instance %08x, ops %08x, plat %08x\n",
73+
ret = uclass_next_device_check(&dev)) {
74+
printf("entry %d - instance %08x, ops %08x, plat %08x, status %i\n",
7575
i++, (uint)map_to_sysmem(dev),
7676
(uint)map_to_sysmem(dev->driver->ops),
77-
(uint)map_to_sysmem(dev_get_plat(dev)));
77+
(uint)map_to_sysmem(dev_get_plat(dev)),
78+
ret);
79+
if (ret)
80+
err = ret;
7881
}
7982

80-
return cmd_process_error(cmdtp, ret);
83+
return cmd_process_error(cmdtp, err);
8184
}
8285

8386
static struct cmd_tbl demo_commands[] = {

cmd/gpio.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,24 @@ static int do_gpio_status(bool all, const char *gpio_name)
7777
struct udevice *dev;
7878
int banklen;
7979
int flags;
80-
int ret;
80+
int ret, err = 0;
8181

8282
flags = 0;
8383
if (gpio_name && !*gpio_name)
8484
gpio_name = NULL;
85-
for (ret = uclass_first_device(UCLASS_GPIO, &dev);
85+
for (ret = uclass_first_device_check(UCLASS_GPIO, &dev);
8686
dev;
87-
ret = uclass_next_device(&dev)) {
87+
ret = uclass_next_device_check(&dev)) {
8888
const char *bank_name;
8989
int num_bits;
9090

91+
if (ret) {
92+
printf("GPIO device %s probe error %i\n",
93+
dev->name, ret);
94+
err = ret;
95+
continue;
96+
}
97+
9198
flags |= FLAG_SHOW_BANK;
9299
if (all)
93100
flags |= FLAG_SHOW_ALL;
@@ -120,7 +127,7 @@ static int do_gpio_status(bool all, const char *gpio_name)
120127
flags |= FLAG_SHOW_NEWLINE;
121128
}
122129

123-
return ret;
130+
return err;
124131
}
125132
#endif
126133

cmd/pmic.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,26 @@ static int do_list(struct cmd_tbl *cmdtp, int flag, int argc,
5151
char *const argv[])
5252
{
5353
struct udevice *dev;
54-
int ret;
54+
int ret, err = 0;
5555

5656
printf("| %-*.*s| %-*.*s| %s @ %s\n",
5757
LIMIT_DEV, LIMIT_DEV, "Name",
5858
LIMIT_PARENT, LIMIT_PARENT, "Parent name",
5959
"Parent uclass", "seq");
6060

61-
for (ret = uclass_first_device(UCLASS_PMIC, &dev); dev;
62-
ret = uclass_next_device(&dev)) {
61+
for (ret = uclass_first_device_check(UCLASS_PMIC, &dev); dev;
62+
ret = uclass_next_device_check(&dev)) {
6363
if (ret)
64-
continue;
64+
err = ret;
6565

66-
printf("| %-*.*s| %-*.*s| %s @ %d\n",
66+
printf("| %-*.*s| %-*.*s| %s @ %d | status: %i\n",
6767
LIMIT_DEV, LIMIT_DEV, dev->name,
6868
LIMIT_PARENT, LIMIT_PARENT, dev->parent->name,
69-
dev_get_uclass_name(dev->parent), dev_seq(dev->parent));
69+
dev_get_uclass_name(dev->parent), dev_seq(dev->parent),
70+
ret);
7071
}
7172

72-
if (ret)
73+
if (err)
7374
return CMD_RET_FAILURE;
7475

7576
return CMD_RET_SUCCESS;

cmd/regulator.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static void do_status_detail(struct udevice *dev,
205205
constraint(" * mode id:", mode, mode_name);
206206
}
207207

208-
static void do_status_line(struct udevice *dev)
208+
static void do_status_line(struct udevice *dev, int status)
209209
{
210210
struct dm_regulator_uclass_plat *pdata;
211211
int current, value, mode;
@@ -231,6 +231,7 @@ static void do_status_line(struct udevice *dev)
231231
printf("%-10s", mode_name);
232232
else
233233
printf("%-10s", "-");
234+
printf(" %i", status);
234235
printf("\n");
235236
}
236237

@@ -250,11 +251,11 @@ static int do_status(struct cmd_tbl *cmdtp, int flag, int argc,
250251
}
251252

252253
/* Show all of them in a list, probing them as needed */
253-
printf("%-20s %-10s %10s %10s %-10s\n", "Name", "Enabled", "uV", "mA",
254-
"Mode");
255-
for (ret = uclass_first_device(UCLASS_REGULATOR, &dev); dev;
256-
ret = uclass_next_device(&dev))
257-
do_status_line(dev);
254+
printf("%-20s %-10s %10s %10s %-10s %s\n", "Name", "Enabled", "uV", "mA",
255+
"Mode", "Status");
256+
for (ret = uclass_first_device_check(UCLASS_REGULATOR, &dev); dev;
257+
ret = uclass_next_device_check(&dev))
258+
do_status_line(dev, ret);
258259

259260
return CMD_RET_SUCCESS;
260261
}

0 commit comments

Comments
 (0)