Re: [PATCH v5 09/15] cmd: List all uclass devices regardless of probe error

2022-10-02 Thread Simon Glass
Hi Michal,

On Sun, 2 Oct 2022 at 13:10, Michal Suchánek  wrote:
>
> Hello,
>
> On Thu, Sep 29, 2022 at 04:00:42AM -0600, Simon Glass wrote:
> > On Tue, 27 Sept 2022 at 15:38, Michal Suchanek  wrote:
> > >
> > > 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 
> > > ---
> > >  cmd/adc.c   | 22 ++
> > >  cmd/demo.c  | 16 ++--
> > >  cmd/gpio.c  | 15 +++
> > >  cmd/pmic.c  | 15 ---
> > >  cmd/regulator.c | 13 +++--
> > >  5 files changed, 46 insertions(+), 35 deletions(-)
> >
> > With the errno change dropped:
>
> Can you be please more sspecific about 'the errno change' and the
> problem with it?

I mean please print the errno instead of converting to a string. That
change needs to be done separately.

Regards,
Simon

> >
> > Reviewed-by: Simon Glass 


Re: [PATCH v5 09/15] cmd: List all uclass devices regardless of probe error

2022-10-02 Thread Michal Suchánek
Hello,

On Thu, Sep 29, 2022 at 04:00:42AM -0600, Simon Glass wrote:
> On Tue, 27 Sept 2022 at 15:38, Michal Suchanek  wrote:
> >
> > 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 
> > ---
> >  cmd/adc.c   | 22 ++
> >  cmd/demo.c  | 16 ++--
> >  cmd/gpio.c  | 15 +++
> >  cmd/pmic.c  | 15 ---
> >  cmd/regulator.c | 13 +++--
> >  5 files changed, 46 insertions(+), 35 deletions(-)
> 
> With the errno change dropped:

Can you be please more sspecific about 'the errno change' and the
problem with it?

Thanks

Michal

> 
> Reviewed-by: Simon Glass 


Re: [PATCH v5 09/15] cmd: List all uclass devices regardless of probe error

2022-09-29 Thread Simon Glass
On Tue, 27 Sept 2022 at 15:38, Michal Suchanek  wrote:
>
> 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 
> ---
>  cmd/adc.c   | 22 ++
>  cmd/demo.c  | 16 ++--
>  cmd/gpio.c  | 15 +++
>  cmd/pmic.c  | 15 ---
>  cmd/regulator.c | 13 +++--
>  5 files changed, 46 insertions(+), 35 deletions(-)

With the errno change dropped:

Reviewed-by: Simon Glass 


[PATCH v5 09/15] cmd: List all uclass devices regardless of probe error

2022-09-27 Thread Michal Suchanek
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 
---
 cmd/adc.c   | 22 ++
 cmd/demo.c  | 16 ++--
 cmd/gpio.c  | 15 +++
 cmd/pmic.c  | 15 ---
 cmd/regulator.c | 13 +++--
 5 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/cmd/adc.c b/cmd/adc.c
index 1c5d3e10a3..7dcb44eb61 100644
--- a/cmd/adc.c
+++ b/cmd/adc.c
@@ -6,29 +6,27 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 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, );
-   if (ret) {
-   printf("No available ADC device\n");
-   return CMD_RET_FAILURE;
-   }
+   ret = err = uclass_first_device_check(UCLASS_ADC, );
 
-   do {
-   printf("- %s\n", dev->name);
+   while (dev) {
+   printf("- %s status: %s\n", dev->name,
+  ret ? errno_str(ret) : "OK");
 
-   ret = uclass_next_device();
+   ret = uclass_next_device_check();
if (ret)
-   return CMD_RET_FAILURE;
-   } while (dev);
+   err = ret;
+   }
 
-   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,
diff --git a/cmd/demo.c b/cmd/demo.c
index 571f562ec6..56551f269d 100644
--- a/cmd/demo.c
+++ b/cmd/demo.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -64,20 +65,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[])
 {
struct udevice *dev;
-   int i, ret;
+   int i, ret, err = 0;
 
puts("Demo uclass entries:\n");
 
-   for (i = 0, ret = uclass_first_device(UCLASS_DEMO, );
+   for (i = 0, ret = uclass_first_device_check(UCLASS_DEMO, );
 dev;
-ret = uclass_next_device()) {
-   printf("entry %d - instance %08x, ops %08x, plat %08x\n",
+ret = uclass_next_device_check()) {
+   printf("entry %d - instance %08x, ops %08x, plat %08x, probe %i 
(%s)\n",
   i++, (uint)map_to_sysmem(dev),
   (uint)map_to_sysmem(dev->driver->ops),
-  (uint)map_to_sysmem(dev_get_plat(dev)));
+  (uint)map_to_sysmem(dev_get_plat(dev)),
+  ret, errno_str(ret));
+   if (ret)
+   err = ret;
}
 
-   return cmd_process_error(cmdtp, ret);
+   return cmd_process_error(cmdtp, err);
 }
 
 static struct cmd_tbl demo_commands[] = {
diff --git a/cmd/gpio.c b/cmd/gpio.c
index 53e9ce666f..4bf410a9e7 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -77,17 +77,24 @@ static int do_gpio_status(bool all, const char *gpio_name)
struct udevice *dev;
int banklen;
int flags;
-   int ret;
+   int ret, err = 0;
 
flags = 0;
if (gpio_name && !*gpio_name)
gpio_name = NULL;
-   for (ret = uclass_first_device(UCLASS_GPIO, );
+   for (ret = uclass_first_device_check(UCLASS_GPIO, );
 dev;
-ret = uclass_next_device()) {
+ret = uclass_next_device_check()) {
const char *bank_name;
int num_bits;
 
+   if (ret) {
+   printf("GPIO device %s probe error %i (%s)\n",
+  dev->name, ret, errno_str(ret));
+   err = ret;
+   continue;
+   }
+
flags |= FLAG_SHOW_BANK;
if (all)
flags |= FLAG_SHOW_ALL;
@@ -120,7 +127,7 @@ static int do_gpio_status(bool all, const char *gpio_name)
flags |= FLAG_SHOW_NEWLINE;
}
 
-   return ret;
+   return err;
 }
 #endif
 
diff --git a/cmd/pmic.c b/cmd/pmic.c
index 0cb44d0740..d5624241e6 100644
--- a/cmd/pmic.c
+++ b/cmd/pmic.c
@@ -51,25 +51,26 @@ static int do_list(struct cmd_tbl *cmdtp, int flag, int 
argc,
   char *const argv[])
 {
struct udevice *dev;
-   int ret;
+   int ret, err = 0;
 
printf("| %-*.*s| %-*.*s| %s @ %s\n",
   LIMIT_DEV, LIMIT_DEV, "Name",
   LIMIT_PARENT, LIMIT_PARENT, "Parent name",
   "Parent uclass", "seq");
 
-   for (ret = uclass_first_device(UCLASS_PMIC, ); dev;
-ret = uclass_next_device()) {
+   for (ret = uclass_first_device_check(UCLASS_PMIC, ); dev;
+