
Hi Michal,
On Fri, 19 Aug 2022 at 14:23, Michal Suchanek msuchanek@suse.de wrote:
When probing a device fails NULL pointer is returned, and other devices cannot be iterated. Skip to next device on error instead.
Fixes: 6494d708bf ("dm: Add base driver model support")
I think you should drop this as you are doing a change of behaviour, not fixing a bug!
Signed-off-by: Michal Suchanek msuchanek@suse.de
v2: - Fix up tests v3: - Fix up API doc - Correctly forward error from uclass_get - Do not return an error when last device fails to probe - Drop redundant initialization - Wrap at 80 columns
drivers/core/uclass.c | 32 ++++++++++++++++++++++++-------- include/dm/uclass.h | 13 ++++++++----- test/dm/test-fdt.c | 20 ++++++++++++++++---- 3 files changed, 48 insertions(+), 17 deletions(-)
Unfortunately this still fails one test. Try 'make qcheck' to see it - it is ethernet.
I actually think you should create new functions for this feature, e.g.uclass_first_device_ok(), since it makes it impossible to see what when wrong with a device in the middle.
I have long had all this in my mind. One idea for a future change is to return the error, but set dev, so that the caller knows there is a device, which failed. When we are at the end, dev is set to NULL.
Then we could iterate like this:
struct udevice *dev;
for (ret = uclass_first_device(UCLASS_FRED, &dev); dev; ret = uclass_next_device(&dev)) { if (ret) log_warning("%s failed to probe\n", dev->name); else .... use device }
Regards, Simon