summaryrefslogtreecommitdiff
path: root/common/spl/spl_mmc.c
diff options
context:
space:
mode:
authorSean Anderson <seanga2@gmail.com>2023-11-08 11:48:40 -0500
committerTom Rini <trini@konsulko.com>2023-11-16 13:49:14 -0500
commit73c40fcb7367f5a431c987f7da0420c058a939fc (patch)
treeafd19a4c46fbf50ee3d4dd2fb323da03bc28ac56 /common/spl/spl_mmc.c
parent33c8d01a4d20ab1f7cb59bd9860e42196d6ddb4e (diff)
downloadu-boot-73c40fcb7367f5a431c987f7da0420c058a939fc.tar.gz
u-boot-73c40fcb7367f5a431c987f7da0420c058a939fc.tar.bz2
u-boot-73c40fcb7367f5a431c987f7da0420c058a939fc.zip
spl: Refactor spl_load_info->read to use units of bytes
Simplify things a bit for callers of spl_load_info->read by refactoring it to use units of bytes instead of bl_len. This generally simplifies the logic, as MMC is the only loader which actually works in sectors. It will also allow further refactoring to remove the special-case handling of filename. spl_load_legacy_img already works in units of bytes (oops) so it doesn't need to be changed. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/spl/spl_mmc.c')
-rw-r--r--common/spl/spl_mmc.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 3d7551a7da..9f41ea648c 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -62,12 +62,14 @@ static int mmc_load_legacy(struct spl_image_info *spl_image,
return 0;
}
-static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
- ulong count, void *buf)
+static ulong h_spl_load_read(struct spl_load_info *load, ulong off,
+ ulong size, void *buf)
{
- struct mmc *mmc = load->priv;
+ struct blk_desc *bd = load->priv;
+ lbaint_t sector = off >> bd->log2blksz;
+ lbaint_t count = size >> bd->log2blksz;
- return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
+ return blk_dread(bd, sector, count, buf) << bd->log2blksz;
}
static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part)
@@ -105,21 +107,23 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
struct spl_load_info load;
debug("Found FIT\n");
- load.priv = mmc;
+ load.priv = bd;
load.filename = NULL;
- load.bl_len = mmc->read_bl_len;
+ load.bl_len = bd->blksz;
load.read = h_spl_load_read;
- ret = spl_load_simple_fit(spl_image, &load, sector, header);
+ ret = spl_load_simple_fit(spl_image, &load,
+ sector << bd->log2blksz, header);
} else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) &&
valid_container_hdr((void *)header)) {
struct spl_load_info load;
- load.priv = mmc;
+ load.priv = bd;
load.filename = NULL;
- load.bl_len = mmc->read_bl_len;
+ load.bl_len = bd->blksz;
load.read = h_spl_load_read;
- ret = spl_load_imx_container(spl_image, &load, sector);
+ ret = spl_load_imx_container(spl_image, &load,
+ sector << bd->log2blksz);
} else {
ret = mmc_load_legacy(spl_image, bootdev, mmc, sector, header);
}