diff options
author | Simon Glass <sjg@chromium.org> | 2022-02-28 12:08:35 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-04-06 14:03:17 -0400 |
commit | 49e8668181df501f263751b2e9bbb5ff737819d1 (patch) | |
tree | 50ba086e7342efbdb50046c69326f25fb9687d09 /drivers/block | |
parent | e86b6f71002e5892c28acd206e68d13adc76c4b7 (diff) | |
download | u-boot-WIP/2022-04-06-various-verified-boot-bugfixes.zip u-boot-WIP/2022-04-06-various-verified-boot-bugfixes.tar.gz u-boot-WIP/2022-04-06-various-verified-boot-bugfixes.tar.bz2 |
dm: blk: Expand iteration and add testsWIP/2022-04-06-various-verified-boot-bugfixes
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.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index f9f05f4..f1e4a85 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; |