[PATCH 4/6] scsi: move scsi_scan() call out of scsi_get_blk_by_uuid()

David Lechner dlechner at baylibre.com
Thu Mar 26 23:59:26 CET 2026


Move scsi_scan() call out of scsi_get_blk_by_uuid().

The only caller, env_scsi_get_part(), should be managing this call since
it may also want to use different ways to get the partition information
in the future.

Signed-off-by: David Lechner <dlechner at baylibre.com>
---
 drivers/scsi/scsi-uclass.c | 6 ------
 env/scsi.c                 | 6 ++++++
 include/scsi.h             | 2 ++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
index e7870d7f831..39b4c7476d4 100644
--- a/drivers/scsi/scsi-uclass.c
+++ b/drivers/scsi/scsi-uclass.c
@@ -29,15 +29,9 @@ int scsi_get_blk_by_uuid(const char *uuid,
 			 struct blk_desc **blk_desc_ptr,
 			 struct disk_partition *part_info_ptr)
 {
-	static int is_scsi_scanned;
 	struct blk_desc *blk;
 	int i, ret;
 
-	if (!is_scsi_scanned) {
-		scsi_scan(false /* no verbose */);
-		is_scsi_scanned = 1;
-	}
-
 	for (i = 0; i < blk_find_max_devnum(UCLASS_SCSI) + 1; i++) {
 		ret = blk_get_desc(UCLASS_SCSI, i, &blk);
 		if (ret)
diff --git a/env/scsi.c b/env/scsi.c
index f376f731870..1787dcca92a 100644
--- a/env/scsi.c
+++ b/env/scsi.c
@@ -33,8 +33,14 @@ static struct env_scsi_info env_part;
 
 static inline struct env_scsi_info *env_scsi_get_part(void)
 {
+	static bool is_scsi_scanned;
 	struct env_scsi_info *ep = &env_part;
 
+	if (!is_scsi_scanned) {
+		scsi_scan(false /* no verbose */);
+		is_scsi_scanned = true;
+	}
+
 	if (scsi_get_blk_by_uuid(CONFIG_ENV_SCSI_PART_UUID, &ep->blk, &ep->part))
 		return NULL;
 
diff --git a/include/scsi.h b/include/scsi.h
index c244120c283..2520a8b8fe6 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -356,6 +356,8 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);
 /**
  * scsi_get_blk_by_uuid() - Provides SCSI partition information.
  *
+ * scsi_scan() must have been called before calling this function.
+ *
  * @uuid:		UUID of the partition for fetching its info
  * @blk_desc_ptr:	Provides the blk descriptor
  * @part_info_ptr:	Provides partition info

-- 
2.43.0



More information about the U-Boot mailing list