[U-Boot] [PATCH] dm: core: Fix regression caused by c1d6f91

Joe Hershberger joe.hershberger at ni.com
Wed Apr 29 06:14:33 CEST 2015


The change to refactor these functions created a regression.

commit c1d6f91952d0761f61b0f0f96e4c7aa32eee2788
Author: Przemyslaw Marczak <p.marczak at samsung.com>
Date:   Wed Apr 15 13:07:17 2015 +0200
dm: core: add internal functions for getting the device without probe

With this change, the dm unit tests started failing with a probe error
-22 in the dm_test_children test.

Test: dm_test_children
test/dm/core.c:544, dm_test_children(): 0 == ret: Expected 0, got -22

This restores the original behavior which would avoid a probe on invalid
device pointers.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
---

 drivers/core/uclass.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 04e939d..898c1fc 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -174,7 +174,7 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp)
 	if (ret)
 		return ret;
 	if (list_empty(&uc->dev_head))
-		return 0;
+		return -ENODEV;
 
 	*devp = list_first_entry(&uc->dev_head, struct udevice, uclass_node);
 
@@ -187,7 +187,7 @@ int uclass_find_next_device(struct udevice **devp)
 
 	*devp = NULL;
 	if (list_is_last(&dev->uclass_node, &dev->uclass->dev_head))
-		return 0;
+		return -ENODEV;
 
 	*devp = list_entry(dev->uclass_node.next, struct udevice, uclass_node);
 
@@ -342,6 +342,8 @@ int uclass_first_device(enum uclass_id id, struct udevice **devp)
 
 	*devp = NULL;
 	ret = uclass_find_first_device(id, &dev);
+	if (ret == -ENODEV)
+		return 0;
 	return uclass_get_device_tail(dev, ret, devp);
 }
 
@@ -352,6 +354,8 @@ int uclass_next_device(struct udevice **devp)
 
 	*devp = NULL;
 	ret = uclass_find_next_device(&dev);
+	if (ret == -ENODEV)
+		return 0;
 	return uclass_get_device_tail(dev, ret, devp);
 }
 
-- 
1.7.11.5



More information about the U-Boot mailing list