[PATCH v4.1 10/9] spl: Convert NVMe to spl_load

Sean Anderson sean.anderson at seco.com
Mon Jul 24 20:09:35 CEST 2023


This converts the blk load method (used exclusively by NVMe) to use
spl_load. As a consequence, it also adds support for LOAD_FIT_FULL and
IMX images.

Signed-off-by: Sean Anderson <sean.anderson at seco.com>
---
As suggested by Heinrich.

 common/spl/spl_blk_fs.c | 62 ++++++++++-------------------------------
 1 file changed, 14 insertions(+), 48 deletions(-)

diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
index d97adc4d39a..a0992f3838a 100644
--- a/common/spl/spl_blk_fs.c
+++ b/common/spl/spl_blk_fs.c
@@ -50,6 +50,12 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
 	loff_t actlen, filesize;
 	struct blk_dev dev;
 	int ret;
+	struct spl_load_info load = {
+		.read = spl_fit_read,
+		.bl_len = 1,
+		.filename = filename,
+		.priv = &dev,
+	};
 
 	blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
 	if (!blk_desc) {
@@ -75,6 +81,13 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
 		goto out;
 	}
 
+	ret = fs_size(filename, &filesize);
+	if (ret) {
+		printf("spl: unable to get file size: %s. Err - %d\n",
+		       filename, ret);
+		goto out;
+	}
+
 	ret = fs_read(filename, (ulong)header, 0,
 		      sizeof(struct legacy_img_hdr), &actlen);
 	if (ret) {
@@ -83,52 +96,5 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
 		goto out;
 	}
 
-	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
-	    image_get_magic(header) == FDT_MAGIC) {
-		struct spl_load_info load;
-
-		debug("Found FIT\n");
-		load.read = spl_fit_read;
-		load.bl_len = 1;
-		load.filename = (void *)filename;
-		load.priv = &dev;
-
-		return spl_load_simple_fit(spl_image, &load, 0, header);
-	}
-
-	ret = spl_parse_image_header(spl_image, bootdev, header);
-	if (ret) {
-		printf("spl: unable to parse image header. Err - %d\n",
-		       ret);
-		goto out;
-	}
-
-	ret = fs_set_blk_dev(dev.ifname, dev.dev_part_str, FS_TYPE_ANY);
-	if (ret) {
-		printf("spl: unable to set blk_dev %s %s. Err - %d\n",
-		       dev.ifname, dev.dev_part_str, ret);
-		goto out;
-	}
-
-	ret = fs_size(filename, &filesize);
-	if (ret) {
-		printf("spl: unable to get file size: %s. Err - %d\n",
-		       filename, ret);
-		goto out;
-	}
-
-	ret = fs_set_blk_dev(dev.ifname, dev.dev_part_str, FS_TYPE_ANY);
-	if (ret) {
-		printf("spl: unable to set blk_dev %s %s. Err - %d\n",
-		       dev.ifname, dev.dev_part_str, ret);
-		goto out;
-	}
-
-	ret = fs_read(filename, (ulong)spl_image->load_addr, 0, filesize,
-		      &actlen);
-	if (ret)
-		printf("spl: unable to read file %s. Err - %d\n",
-		       filename, ret);
-out:
-	return ret;
+	return spl_load(spl_image, bootdev, &load, header, filesize, 0);
 }
-- 
2.35.1.1320.gc452695387.dirty



More information about the U-Boot mailing list