summaryrefslogtreecommitdiff
path: root/test/dm/test-fdt.c
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2020-06-02 02:47:09 +0300
committerSimon Glass <sjg@chromium.org>2020-06-12 05:52:11 +0300
commitbe1a6e94254af205bd67d69e3bdb26b161ccd72f (patch)
tree5bff9218c993494bbb5cbfa8d817b31f2c13d682 /test/dm/test-fdt.c
parent0a6b75f7d8cbf7edc62c7d132b521703f1e2a53d (diff)
downloadu-boot-be1a6e94254af205bd67d69e3bdb26b161ccd72f.tar.xz
dm: uclass: don't assign aliased seq numbers
If there are aliases for an uclass, set the base for the "dynamically" allocated numbers next to the highest alias. Please note, that this might lead to holes in the sequences, depending on the device tree. For example if there is only an alias "ethernet1", the next device seq number would be 2. In particular this fixes a problem with boards which are using ethernet aliases but also might have network add-in cards like the E1000. If the board is started with the add-in card and depending on the order of the drivers, the E1000 might occupy the first ethernet device and mess up all the hardware addresses, because the devices are now shifted by one. Also adapt the test cases to the new handling and add test cases checking the holes in the seq numbers. Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Alex Marginean <alexandru.marginean@nxp.com> Tested-by: Alex Marginean <alexandru.marginean@nxp.com> Acked-by: Vladimir Oltean <olteanv@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Michal Simek <michal.simek@xilinx.com> [on zcu102-revA]
Diffstat (limited to 'test/dm/test-fdt.c')
-rw-r--r--test/dm/test-fdt.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 4fcae03dc5..51f2547409 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -361,20 +361,32 @@ 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 0 */
- ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 0, &dev));
+ /*
+ * 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 1 */
- ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1,
+ /* 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, 1, &dev));
+ 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,
+ true, &dev));
+ ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4,
+ true, &dev));
+
return 0;
}
DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);