From 19006e63e16c4d180be7e6102ba35e4e4dc97d51 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Tue, 14 Nov 2023 14:38:39 +0100 Subject: [PATCH] rimage: manifest: Use DIV_ROUND_UP macro Used DIV_ROUND_UP macro to calculate page count. Signed-off-by: Adrian Warecki --- tools/rimage/src/manifest.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/rimage/src/manifest.c b/tools/rimage/src/manifest.c index 84176418df22..eb9fc322535f 100644 --- a/tools/rimage/src/manifest.c +++ b/tools/rimage/src/manifest.c @@ -787,8 +787,7 @@ int man_write_fw_v1_5_sue(struct image *image) /* write preload page count */ preload_size = image->image_end - MAN_DESC_OFFSET_V1_5_SUE; - preload_size += MAN_PAGE_SIZE - (preload_size % MAN_PAGE_SIZE); - m->desc.header.preload_page_count = preload_size / MAN_PAGE_SIZE; + m->desc.header.preload_page_count = DIV_ROUND_UP(preload_size, MAN_PAGE_SIZE); fprintf(stdout, "Firmware file size 0x%x page count %d\n", FILE_TEXT_OFFSET_V1_5_SUE - MAN_DESC_OFFSET_V1_5_SUE + @@ -985,8 +984,7 @@ int man_write_fw_meu_v1_5(struct image *image) /* write preload page count */ preload_size = meta->comp_desc[0].limit_offset - MAN_DESC_OFFSET_V1_5; - preload_size += MAN_PAGE_SIZE - (preload_size % MAN_PAGE_SIZE); - desc->header.preload_page_count = preload_size / MAN_PAGE_SIZE; + desc->header.preload_page_count = DIV_ROUND_UP(preload_size, MAN_PAGE_SIZE); /* calculate hash for each module */ man_hash_modules(image, desc); @@ -1071,8 +1069,7 @@ int man_write_fw_meu_v1_8(struct image *image) /* write preload page count */ preload_size = meta->comp_desc[0].limit_offset - MAN_DESC_OFFSET_V1_8; - preload_size += MAN_PAGE_SIZE - (preload_size % MAN_PAGE_SIZE); - desc->header.preload_page_count = preload_size / MAN_PAGE_SIZE; + desc->header.preload_page_count = DIV_ROUND_UP(preload_size, MAN_PAGE_SIZE); /* calculate hash for each module */ man_hash_modules(image, desc); @@ -1160,8 +1157,7 @@ int man_write_fw_meu_v2_5(struct image *image) /* write preload page count */ preload_size = meta->comp_desc[0].limit_offset - MAN_DESC_OFFSET_V1_8; - preload_size += MAN_PAGE_SIZE - (preload_size % MAN_PAGE_SIZE); - desc->header.preload_page_count = preload_size / MAN_PAGE_SIZE; + desc->header.preload_page_count = DIV_ROUND_UP(preload_size, MAN_PAGE_SIZE); /* calculate hash for each module */ man_hash_modules(image, desc);