[PATCH v4 18/21] dm: blk: Do not use uclass_next_device_err

Michal Suchanek msuchanek at suse.de
Sun Sep 25 10:28:11 CEST 2022


blk_first_device_err/blk_next_device_err uses
uclass_first_device_err/uclass_next_device_err for device iteration.

Although the function names superficially match the return value from
uclass_first_device_err/uclass_next_device_err is never used
meaningfully, and uclass_first_device/uclass_next_device works equally
well for this purpose.

In the following patch the semantic of
uclass_first_device_err/uclass_next_device_err will be changed to be
based on uclass_first_device_check/uclass_next_device_check breaking
this sole user that uses uclass_next_device_err for iteration.

Signed-off-by: Michal Suchanek <msuchanek at suse.de>
---
 drivers/block/blk-uclass.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 992f8ad3da..35beedfdf7 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -583,11 +583,9 @@ int blk_find_next(enum blk_flag_t flags, struct udevice **devp)
 
 int blk_first_device_err(enum blk_flag_t flags, struct udevice **devp)
 {
-	int ret;
-
-	for (ret = uclass_first_device_err(UCLASS_BLK, devp);
-	     !ret;
-	     ret = uclass_next_device_err(devp)) {
+	for (uclass_first_device(UCLASS_BLK, devp);
+	     *devp;
+	     uclass_next_device(devp)) {
 		if (!blk_flags_check(*devp, flags))
 			return 0;
 	}
@@ -597,11 +595,9 @@ int blk_first_device_err(enum blk_flag_t flags, struct udevice **devp)
 
 int blk_next_device_err(enum blk_flag_t flags, struct udevice **devp)
 {
-	int ret;
-
-	for (ret = uclass_next_device_err(devp);
-	     !ret;
-	     ret = uclass_next_device_err(devp)) {
+	for (uclass_next_device(devp);
+	     *devp;
+	     uclass_next_device(devp)) {
 		if (!blk_flags_check(*devp, flags))
 			return 0;
 	}
-- 
2.37.3



More information about the U-Boot mailing list