aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-04-23 20:02:05 -0600
committerSimon Glass <sjg@chromium.org>2017-06-01 07:03:04 -0600
commit6139281a6473334351c8776643478c0b0e208342 (patch)
tree501de9018b4716ecc19bfcff404b4ea10f65e0ee /test
parente7017a3c7d2f9ff845516675205c99df4ad6eacc (diff)
downloadu-boot-midas-6139281a6473334351c8776643478c0b0e208342.tar.gz
u-boot-midas-6139281a6473334351c8776643478c0b0e208342.tar.bz2
u-boot-midas-6139281a6473334351c8776643478c0b0e208342.zip
dm: blk: Allow finding block devices without probing
Sometimes it is useful to be able to find a block device without also probing it. Add a function for this as well as the associated test. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/blk.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 012bf4cab5..3e34336fae 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -94,3 +94,24 @@ static int dm_test_blk_usb(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_blk_usb, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that we can find block devices without probing them */
+static int dm_test_blk_find(struct unit_test_state *uts)
+{
+ struct udevice *blk, *dev;
+
+ ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
+ IF_TYPE_HOST, 1, 512, 1024, &blk));
+ ut_asserteq(-ENODEV, blk_find_device(IF_TYPE_HOST, 0, &dev));
+ ut_assertok(blk_find_device(IF_TYPE_HOST, 1, &dev));
+ ut_asserteq_ptr(blk, dev);
+ ut_asserteq(false, device_active(dev));
+
+ /* Now activate it */
+ ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
+ ut_asserteq_ptr(blk, dev);
+ ut_asserteq(true, device_active(dev));
+
+ return 0;
+}
+DM_TEST(dm_test_blk_find, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);