[PATCH 10/13] boot: Move decomp_image() into handle_load_op()
Simon Glass
sjg at chromium.org
Wed Mar 25 17:54:19 CET 2026
Decompress is really part of loading, so simplify the code slightly by
moving decompression out of the top-level fit_image_load() function.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
boot/image-fit.c | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/boot/image-fit.c b/boot/image-fit.c
index a59226d42c5..7efd0f30dc5 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -2390,7 +2390,8 @@ static int decomp_image(const void *fit, int noffset, const char *prop_name,
* handle_load_op() - Handle the load operation
*
* Process the load_op and figure out where the image should be loaded, now
- * that it has been located
+ * that it has been located. Decompress and move as necessary to get the image
+ * into the right place - see decomp_image()
*
* @fit: FIT to check
* @noffset: Node offset of the image being loaded
@@ -2402,21 +2403,21 @@ static int decomp_image(const void *fit, int noffset, const char *prop_name,
* @load_op: Load operation to process
* @bootstage_id: ID of starting bootstage to use for progress updates
* @datap: Returns buf
- * @loadp: Returns the address to which the data should be loaded
- * @load_endp: Returns the end address of the data-loading location
+ * @loadp: Returns the address where the data was loaded
+ * @sizep: On entry, the size of the image in bytes. Updated if decompressed
* Return: 0 if OK, -ve on error
*/
static int handle_load_op(const void *fit, int noffset, const char *prop_name,
- void *buf, ulong size,
- enum image_type_t image_type,
+ void *buf, ulong size, enum image_type_t image_type,
enum fit_load_op load_op, int bootstage_id,
- ulong *datap, ulong *loadp, ulong *load_endp)
+ ulong *datap, ulong *loadp, ulong *sizep)
{
- ulong data, load;
+ ulong data, load, load_end;
+ int ret;
data = map_to_sysmem(buf);
load = data;
- *load_endp = 0;
+ load_end = 0;
if (load_op == FIT_LOAD_IGNORED) {
log_debug("load_op: not loading\n");
/* Don't load */
@@ -2437,9 +2438,9 @@ static int handle_load_op(const void *fit, int noffset, const char *prop_name,
image_start = map_to_sysmem(fit);
image_end = image_start + fit_get_size(fit);
- *load_endp = load + size;
+ load_end = load + size;
if (image_type != IH_TYPE_KERNEL &&
- load < image_end && *load_endp > image_start) {
+ load < image_end && load_end > image_start) {
printf("Error: %s overwritten\n", prop_name);
return -EXDEV;
}
@@ -2449,6 +2450,13 @@ static int handle_load_op(const void *fit, int noffset, const char *prop_name,
} else {
load = data; /* No load address specified */
}
+
+ ret = decomp_image(fit, noffset, prop_name, buf, image_type,
+ load_op, bootstage_id, data, &load, sizep,
+ load_end);
+ if (ret)
+ return ret;
+
*datap = data;
*loadp = load;
@@ -2467,7 +2475,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
const char *fit_base_uname_config;
const void *fit;
void *buf;
- ulong load, load_end, data, len;
+ ulong load, data, len;
uint8_t os_arch;
const char *prop_name;
int ret;
@@ -2497,13 +2505,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
return ret;
ret = handle_load_op(fit, noffset, prop_name, buf, len, image_type,
- load_op, bootstage_id, &data, &load, &load_end);
- if (ret)
- return ret;
-
- ret = decomp_image(fit, noffset, prop_name, buf, image_type,
- load_op, bootstage_id, data, &load, &len,
- load_end);
+ load_op, bootstage_id, &data, &load, &len);
if (ret)
return ret;
--
2.43.0
More information about the U-Boot
mailing list