Skip to content

Commit

Permalink
rimage: manifest: Use DIV_ROUND_UP macro
Browse files Browse the repository at this point in the history
Used DIV_ROUND_UP macro to calculate page count.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
  • Loading branch information
softwarecki committed Nov 27, 2023
1 parent 36b2f68 commit 19006e6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tools/rimage/src/manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 19006e6

Please sign in to comment.