[PATCH v3 06/28] dm: core: Switch binding to use new sequence numbers

Simon Glass sjg at chromium.org
Thu Dec 17 05:20:11 CET 2020


Update the core logic to use the new approach. For now the old code is
left as is. Update one test so it still passes.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 drivers/core/device.c | 5 +----
 test/dm/bus.c         | 3 ++-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 8d1287f9a19..1e681333d35 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -661,12 +661,9 @@ int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq,
 	struct udevice *dev;
 
 	*devp = NULL;
-	if (seq_or_req_seq == -1)
-		return -ENODEV;
 
 	list_for_each_entry(dev, &parent->child_head, sibling_node) {
-		if ((find_req_seq ? dev->req_seq : dev_seq(dev)) ==
-				seq_or_req_seq) {
+		if (dev->sqq == seq_or_req_seq) {
 			*devp = dev;
 			return 0;
 		}
diff --git a/test/dm/bus.c b/test/dm/bus.c
index 9e81b1da1f0..77555e52937 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -159,9 +159,10 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)
 	ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, true, &dev));
 	ut_assertok(device_find_child_by_seq(bus, 0, true, &dev));
 	ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
-	ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 0, false, &dev));
+	ut_asserteq(0, device_find_child_by_seq(bus, 0, false, &dev));
 	ut_assertok(device_get_child_by_seq(bus, 0, &dev));
 	ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+	ut_asserteq(0, device_find_child_by_seq(bus, 0, false, &dev));
 
 	/* There is no device with sequence number 2 */
 	ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 2, false, &dev));
-- 
2.29.2.684.gfbc64c5ab5-goog



More information about the U-Boot mailing list