]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ
authorSimon Glass <sjg@chromium.org>
Thu, 17 Dec 2020 04:20:27 +0000 (21:20 -0700)
committerSimon Glass <sjg@chromium.org>
Sat, 19 Dec 2020 03:32:21 +0000 (20:32 -0700)
Check that this flag operates as expected. This patch is not earlier in
this series since is uses the new behaviour of dev_seq().

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

index fb838049be5fccd96811736966cda4d2784f7349..d49bee43aaef23f86d37589753ccdbdb73b5c59f 100644 (file)
@@ -37,6 +37,7 @@
                testfdt3 = "/b-test";
                testfdt5 = "/some-bus/c-test@5";
                testfdt8 = "/a-test";
+               testfdtm1 = &testfdtm1;
                fdt-dummy0 = "/translation-test@8000/dev@0,0";
                fdt-dummy1 = "/translation-test@8000/dev@1,100";
                fdt-dummy2 = "/translation-test@8000/dev@2,200";
                idle-state = <0xabcd>;
        };
 
+       testfdtm0 {
+               compatible = "denx,u-boot-fdtm-test";
+       };
+
+       testfdtm1: testfdtm1 {
+               compatible = "denx,u-boot-fdtm-test";
+       };
+
+       testfdtm2 {
+               compatible = "denx,u-boot-fdtm-test";
+       };
+
        timer@0 {
                compatible = "sandbox,timer";
                clock-frequency = <1000000>;
index e952a9967c243cf7fd4473a2eec153d4d8e6be68..ae4425d7a57a24202102a3a46ce934b9bbf72b83 100644 (file)
@@ -16,6 +16,7 @@ enum uclass_id {
        UCLASS_DEMO,
        UCLASS_TEST,
        UCLASS_TEST_FDT,
+       UCLASS_TEST_FDT_MANUAL,
        UCLASS_TEST_BUS,
        UCLASS_TEST_PROBE,
        UCLASS_TEST_DUMMY,
index f73cc33d9be76c9d19e0fe7c649a599c3d5c2d4e..87e09f19cd1bdacd26ee609841349b3f147752d3 100644 (file)
@@ -126,6 +126,23 @@ UCLASS_DRIVER(testfdt) = {
        .flags          = DM_UC_FLAG_SEQ_ALIAS,
 };
 
+static const struct udevice_id testfdtm_ids[] = {
+       { .compatible = "denx,u-boot-fdtm-test" },
+       { }
+};
+
+U_BOOT_DRIVER(testfdtm_drv) = {
+       .name   = "testfdtm_drv",
+       .of_match       = testfdtm_ids,
+       .id     = UCLASS_TEST_FDT_MANUAL,
+};
+
+UCLASS_DRIVER(testfdtm) = {
+       .name           = "testfdtm",
+       .id             = UCLASS_TEST_FDT_MANUAL,
+       .flags          = DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ,
+};
+
 struct dm_testprobe_pdata {
        int probe_err;
 };
@@ -399,6 +416,31 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_fdt_uclass_seq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
+/* More tests for sequence numbers */
+static int dm_test_fdt_uclass_seq_manual(struct unit_test_state *uts)
+{
+       struct udevice *dev;
+
+       /*
+        * Since DM_UC_FLAG_NO_AUTO_SEQ is set for this uclass, only testfdtm1
+        * should get a sequence number assigned
+        */
+       ut_assertok(uclass_get_device(UCLASS_TEST_FDT_MANUAL, 0, &dev));
+       ut_asserteq_str("testfdtm0", dev->name);
+       ut_asserteq(-1, dev_seq(dev));
+
+       ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT_MANUAL, 1, &dev));
+       ut_asserteq_str("testfdtm1", dev->name);
+       ut_asserteq(1, dev_seq(dev));
+
+       ut_assertok(uclass_get_device(UCLASS_TEST_FDT_MANUAL, 2, &dev));
+       ut_asserteq_str("testfdtm2", dev->name);
+       ut_asserteq(-1, dev_seq(dev));
+
+       return 0;
+}
+DM_TEST(dm_test_fdt_uclass_seq_manual, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
 /* Test that we can find a device by device tree offset */
 static int dm_test_fdt_offset(struct unit_test_state *uts)
 {