diff mbox series

[07/27] dm: core: Switch binding to use new sequence numbers

Message ID 20201130015402.2328621-6-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show
Series dm: Change the way sequence numbers are implemented | expand

Commit Message

Simon Glass Nov. 30, 2020, 1:53 a.m. UTC
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@chromium.org>
---

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

Patch

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 2f449b3e8fa..bd58a9e946d 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -667,12 +667,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 27b72666457..e1fa67d91e1 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -160,9 +160,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));