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);