spl: Only support bl_len when we have to
Aligning addresses and sizes causes overhead which is unnecessary when we
are not loading from block devices. Remove bl_len when it is not needed.
For example, on iot2050 we save 144 bytes with this patch (once the rest of
this series is applied):
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-144 (-144)
Function old new delta
spl_load_simple_fit 920 904 -16
load_simple_fit 496 444 -52
spl_spi_load_image 384 308 -76
Total: Before=87431, After=87287, chg -0.16%
We use panic() instead of BUILD_BUG_ON in spl_set_bl_len because we still
need to be able to compile it for things like mmc_load_image_raw_sector,
even if that function will not be used.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/common/spl/spl_imx_container.c b/common/spl/spl_imx_container.c
index 7cd674f..b4ea924 100644
--- a/common/spl/spl_imx_container.c
+++ b/common/spl/spl_imx_container.c
@@ -32,13 +32,13 @@
images = (struct boot_img_t *)((u8 *)container +
sizeof(struct container_hdr));
- if (!IS_ALIGNED(images[image_index].offset, info->bl_len)) {
+ if (!IS_ALIGNED(images[image_index].offset, spl_get_bl_len(info))) {
printf("%s: image%d offset not aligned to %u\n",
- __func__, image_index, info->bl_len);
+ __func__, image_index, spl_get_bl_len(info));
return NULL;
}
- size = ALIGN(images[image_index].size, info->bl_len);
+ size = ALIGN(images[image_index].size, spl_get_bl_len(info));
offset = images[image_index].offset + container_offset;
debug("%s: container: %p offset: %lu size: %lu\n", __func__,
@@ -66,7 +66,7 @@
u16 length;
int i, size, ret = 0;
- size = ALIGN(CONTAINER_HDR_ALIGNMENT, info->bl_len);
+ size = ALIGN(CONTAINER_HDR_ALIGNMENT, spl_get_bl_len(info));
/*
* It will not override the ATF code, so safe to use it here,
@@ -100,7 +100,7 @@
debug("Container length %u\n", length);
if (length > CONTAINER_HDR_ALIGNMENT) {
- size = ALIGN(length, info->bl_len);
+ size = ALIGN(length, spl_get_bl_len(info));
free(container);
container = malloc(size);