On Tue, 27 Sept 2022 at 15:40, Michal Suchanek <msucha...@suse.de> wrote: > > Use uclass_first_device_check/uclass_next_device_check to correctly > count buses that fail to probe. > > Fixes: d3e19cf919 ("w1: Add 1-Wire uclass") > Signed-off-by: Michal Suchanek <msucha...@suse.de> > --- > drivers/w1/w1-uclass.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-)
Reviewed-by: Simon Glass <s...@chromium.org> although this is actually broken as it should use uclass_get_device_by_seq() for things that are numbered > > diff --git a/drivers/w1/w1-uclass.c b/drivers/w1/w1-uclass.c > index 52b519c21d..de4f25bcf9 100644 > --- a/drivers/w1/w1-uclass.c > +++ b/drivers/w1/w1-uclass.c > @@ -16,6 +16,7 @@ > > #include <common.h> > #include <dm.h> > +#include <errno.h> > #include <log.h> > #include <w1.h> > #include <w1-eeprom.h> > @@ -182,24 +183,25 @@ static int w1_enumerate(struct udevice *bus) > int w1_get_bus(int busnum, struct udevice **busp) > { > int ret, i = 0; > - > struct udevice *dev; > > - for (ret = uclass_first_device(UCLASS_W1, &dev); > - dev && !ret; > - ret = uclass_next_device(&dev), i++) { > + for (ret = uclass_first_device_check(UCLASS_W1, &dev); > + dev; > + ret = uclass_next_device_check(&dev), i++) { > if (i == busnum) { > + if (ret) { > + debug("Cannot probe w1 bus %d: %d (%s)\n", > + busnum, ret, errno_str(ret)); > + return ret; > + } > *busp = dev; > return 0; > } > } > > - if (!ret) { > - debug("Cannot find w1 bus %d\n", busnum); > - ret = -ENODEV; > - } > + debug("Cannot find w1 bus %d\n", busnum); > > - return ret; > + return -ENODEV; > } > > u8 w1_get_device_family(struct udevice *dev) > -- > 2.37.3 >