]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: Switch over to use new sequence number for dev_seq()
authorSimon Glass <sjg@chromium.org>
Thu, 17 Dec 2020 04:20:26 +0000 (21:20 -0700)
committerSimon Glass <sjg@chromium.org>
Sat, 19 Dec 2020 03:32:21 +0000 (20:32 -0700)
Update this function to use the new sequence number and fix up the test
that deals with this.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
drivers/core/uclass.c
include/dm/device.h
test/dm/test-fdt.c

index f3b766271d307b2149118af222af2b691cc955bc..fb838049be5fccd96811736966cda4d2784f7349 100644 (file)
@@ -33,7 +33,7 @@
                testfdt6 = "/e-test";
                testbus3 = "/some-bus";
                testfdt0 = "/some-bus/c-test@0";
-               testfdt1 = "/some-bus/c-test@1";
+               testfdt12 = "/some-bus/c-test@1";
                testfdt3 = "/b-test";
                testfdt5 = "/some-bus/c-test@5";
                testfdt8 = "/a-test";
index 96b7d16f3fc17cbf9d2d475fc739ad4df38d4a23..c8432b2d1c3246afdd775b94f665c18a9a3738ab 100644 (file)
@@ -306,8 +306,7 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
        uclass_foreach_dev(dev, uc) {
                log_debug("   - %d %d '%s'\n",
                          dev->req_seq, dev_seq(dev), dev->name);
-               if ((find_req_seq ? dev->req_seq : dev_seq(dev)) ==
-                               seq_or_req_seq) {
+               if (dev_seq(dev) == seq_or_req_seq) {
                        *devp = dev;
                        log_debug("   - found\n");
                        return 0;
@@ -692,8 +691,7 @@ int uclass_resolve_seq(struct udevice *dev)
        assert(dev_seq(dev) == -1);
        ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup);
        if (!ret) {
-               dm_warn("Device '%s': seq %d is in use by '%s'\n",
-                       dev->name, dev->req_seq, dup->name);
+               /* Do nothing here for now */
        } else if (ret == -ENODEV) {
                /* Our requested sequence number is available */
                if (dev->req_seq != -1)
index 725e313eacd637991226eaed07e0a6bf02d14949..15731d6c27052c6d1b353d93d42b1e5001c6e2f9 100644 (file)
@@ -192,7 +192,7 @@ static inline bool dev_has_of_node(struct udevice *dev)
 
 static inline int dev_seq(const struct udevice *dev)
 {
-       return dev->seq;
+       return dev->sqq;
 }
 
 /**
index fda2ba6493be932fc3887067c717c1e9d5127bd5..f73cc33d9be76c9d19e0fe7c649a599c3d5c2d4e 100644 (file)
@@ -333,20 +333,28 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
        /* A few basic santiy tests */
        ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 3, true, &dev));
        ut_asserteq_str("b-test", dev->name);
+       ut_asserteq(3, dev_seq(dev));
 
        ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 8, true, &dev));
        ut_asserteq_str("a-test", dev->name);
+       ut_asserteq(8, dev_seq(dev));
 
-       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 5,
-                                                      true, &dev));
+       /*
+        * This device has no alias so gets the next value after all available
+        * aliases. The last alias is testfdt12
+        */
+       ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 13, true, &dev));
+       ut_asserteq_str("d-test", dev->name);
+       ut_asserteq(13, dev_seq(dev));
+
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 9, true,
+                                                      &dev));
        ut_asserteq_ptr(NULL, dev);
 
        /* Test aliases */
        ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 6, &dev));
        ut_asserteq_str("e-test", dev->name);
-
-       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 7,
-                                                      true, &dev));
+       ut_asserteq(6, dev_seq(dev));
 
        /*
         * Note that c-test nodes are not probed since it is not a top-level
@@ -354,6 +362,7 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
         */
        ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 3, &dev));
        ut_asserteq_str("b-test", dev->name);
+       ut_asserteq(3, dev_seq(dev));
 
        /*
         * d-test wants sequence number 3 also, but it can't have it because
@@ -361,31 +370,29 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
         */
        ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev));
        ut_asserteq_str("d-test", dev->name);
-
-       /*
-        * d-test actually gets 9, because thats the next free one after the
-        * aliases.
-        */
-       ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 9, &dev));
-       ut_asserteq_str("d-test", dev->name);
-
-       /* initially no one wants seq 10 */
-       ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 10,
-                                                     &dev));
-       ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
-       ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev));
-
-       /* But now that it is probed, we can find it */
-       ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev));
-       ut_asserteq_str("f-test", dev->name);
-
-       /*
-        * And we should still have holes in our sequence numbers, that is 2
-        * and 4 should not be used.
-        */
-       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2,
+       ut_asserteq(13, dev_seq(dev));
+
+       /* g-test gets the next value after f-test */
+       ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 15, &dev));
+       ut_asserteq_str("g-test", dev->name);
+       ut_asserteq(15, dev_seq(dev));
+
+       /* And we should still have holes in our sequence numbers */
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 0, true,
+                                                      &dev));
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 1, true,
+                                                      &dev));
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2, true,
+                                                      &dev));
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4, true,
+                                                      &dev));
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 7, true,
+                                                      &dev));
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 9, true,
+                                                      &dev));
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 10,
                                                       true, &dev));
-       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4,
+       ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 11,
                                                       true, &dev));
 
        return 0;