dm: core: Correct bug introduced in uclass_first/next_device()
PATCH 1/1 dm: core: Correct bug introduced in uclass_first/next_device()
These functions now rely on uclass_find_first/next_device() and assume that they will either return failure (-ve error code) or a device. In fact, coming to the end of a list is not considered failure and they return 0 in that case.
The logic to deal with this was replaced in commit acb9ca2a with just using uclass_get_device_tail(). Add back the missing logic. This bug was caught by unit tests but since they were broken for other reasons at the time, this was not noticed.
---
drivers/core/uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/core/uclass.c +5 -0
@@ -277,6 +277,7 @@ int uclass_get_device_tail(struct udevice *dev, int ret,if (ret)return ret; +assert (dev); ret =device_probe (dev);if (ret)return ret;
@@ -342,6 +343,8 @@ int uclass_first_device(enum uclass_id id, struct udevice **devp) *devp =NULL ; ret =uclass_find_first_device (id, &dev); +if (!dev) +return 0 ;return uclass_get_device_tail (dev, ret, devp); }
@@ -352,6 +355,8 @@ int uclass_next_device(struct udevice **devp) *devp =NULL ; ret =uclass_find_next_device (&dev); +if (!dev) +return 0 ;return uclass_get_device_tail (dev, ret, devp); }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 1/1 dm: core: Correct bug introduced in uclass_first/next_device()
Hi,
Quoted 10 lines · Simon Glass
These functions now rely on uclass_find_first/next_device() and assume that they will either return failure (-ve error code) or a device. In fact, coming to the end of a list is not considered failure and they return 0 in that case.
The logic to deal with this was replaced in commit
acb9ca2awith just usinguclass_get_device_tail(). Add back the missing logic. This bug was caught by unit tests but since they were broken for other reasons at the time, this was not noticed.
Quoted 5 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/core/uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
Applied to u-boot-dm.
I'll pull this in soon since it does break a number of things.
Regards,
Simon