aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-04-24 23:31:00 -0600
committerTom Rini <trini@konsulko.com>2022-04-25 10:00:03 -0400
commit4e0710a2d007032c8a82ef3af45a0e6e9176a2a7 (patch)
treedbfcd2034200743eac28ce5b8ef3dbcd93fc7e95 /test
parent6aa4fe39122a85ce1ef559139518fa5042406186 (diff)
downloadu-boot-4e0710a2d007032c8a82ef3af45a0e6e9176a2a7.zip
u-boot-4e0710a2d007032c8a82ef3af45a0e6e9176a2a7.tar.gz
u-boot-4e0710a2d007032c8a82ef3af45a0e6e9176a2a7.tar.bz2
dm: core: Allow finding a uclass device by partial name
In some cases two devices are related and the only way to tell is to check that the names partially patch. Add a way to check this without needing to create a new string for the comparison. Fix the comment for device_find_child_by_namelen() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/core.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/dm/core.c b/test/dm/core.c
index 2c73ecf..ebd5044 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1260,3 +1260,18 @@ static int dm_test_get_stats(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_get_stats, UT_TESTF_SCAN_FDT);
+
+/* Test uclass_find_device_by_name() */
+static int dm_test_uclass_find_device(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ ut_assertok(uclass_find_device_by_name(UCLASS_I2C, "i2c@0", &dev));
+ ut_asserteq(-ENODEV,
+ uclass_find_device_by_name(UCLASS_I2C, "i2c@0x", &dev));
+ ut_assertok(uclass_find_device_by_namelen(UCLASS_I2C, "i2c@0x", 5,
+ &dev));
+
+ return 0;
+}
+DM_TEST(dm_test_uclass_find_device, UT_TESTF_SCAN_FDT);