aboutsummaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorSimon Glass2022-02-28 12:08:35 -0700
committerTom Rini2022-04-06 14:03:17 -0400
commit49e8668181df501f263751b2e9bbb5ff737819d1 (patch)
tree50ba086e7342efbdb50046c69326f25fb9687d09 /drivers/block
parente86b6f71002e5892c28acd206e68d13adc76c4b7 (diff)
dm: blk: Expand iteration and add tests
Add some functions which support iteration before probing. Also add tests for the functions. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/blk-uclass.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index f9f05f4e341..f1e4a856467 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -552,6 +552,30 @@ static int blk_flags_check(struct udevice *dev, enum blk_flag_t req_flags)
return flags & req_flags ? 0 : 1;
}
+int blk_find_first(enum blk_flag_t flags, struct udevice **devp)
+{
+ int ret;
+
+ for (ret = uclass_find_first_device(UCLASS_BLK, devp);
+ *devp && !blk_flags_check(*devp, flags);
+ ret = uclass_find_next_device(devp))
+ return 0;
+
+ return -ENODEV;
+}
+
+int blk_find_next(enum blk_flag_t flags, struct udevice **devp)
+{
+ int ret;
+
+ for (ret = uclass_find_next_device(devp);
+ *devp && !blk_flags_check(*devp, flags);
+ ret = uclass_find_next_device(devp))
+ return 0;
+
+ return -ENODEV;
+}
+
int blk_first_device_err(enum blk_flag_t flags, struct udevice **devp)
{
int ret;