aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorYann Gautier <yann.gautier@st.com>2020-06-19 11:38:24 +0200
committerYann Gautier <yann.gautier@foss.st.com>2021-06-04 15:15:18 +0200
commitb6561c1217f5b9be9cc2b66d0c5309ed0b7698cf (patch)
tree110c617d85289fc7e56d347f76ebbb45a9e8b8e3 /drivers
parentc1d732d0db2463998036c678619007da79a25b3f (diff)
downloadtrusted-firmware-a-b6561c1217f5b9be9cc2b66d0c5309ed0b7698cf.tar.gz
refactor(io_stm32image): add header size variable
A variable hdr_sz is created in stm32image_partition_read() function. It just represents the size of the stm32 image header but it really improves the readability of the function. Change-Id: I95ec62a78a4b6c6a75b0d8c8aa0faef8bee424da Signed-off-by: Yann Gautier <yann.gautier@st.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/st/io/io_stm32image.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/st/io/io_stm32image.c b/drivers/st/io/io_stm32image.c
index 48bb4d3575..70e4be30fc 100644
--- a/drivers/st/io/io_stm32image.c
+++ b/drivers/st/io/io_stm32image.c
@@ -250,6 +250,7 @@ static int stm32image_partition_read(io_entity_t *entity, uintptr_t buffer,
uint8_t *local_buffer;
boot_api_image_header_t *header =
(boot_api_image_header_t *)first_lba_buffer;
+ size_t hdr_sz = sizeof(boot_api_image_header_t);
assert(entity != NULL);
assert(buffer != 0U);
@@ -286,16 +287,13 @@ static int stm32image_partition_read(io_entity_t *entity, uintptr_t buffer,
}
/* Part of image already loaded with the header */
- memcpy(local_buffer, (uint8_t *)first_lba_buffer +
- sizeof(boot_api_image_header_t),
- MAX_LBA_SIZE - sizeof(boot_api_image_header_t));
- local_buffer += MAX_LBA_SIZE - sizeof(boot_api_image_header_t);
+ memcpy(local_buffer, (uint8_t *)first_lba_buffer + hdr_sz,
+ MAX_LBA_SIZE - hdr_sz);
+ local_buffer += MAX_LBA_SIZE - hdr_sz;
offset = MAX_LBA_SIZE;
/* New image length to be read */
- local_length = round_up(length -
- ((MAX_LBA_SIZE) -
- sizeof(boot_api_image_header_t)),
+ local_length = round_up(length - ((MAX_LBA_SIZE) - hdr_sz),
stm32image_dev.lba_size);
if ((header->load_address != 0U) &&
@@ -326,7 +324,7 @@ static int stm32image_partition_read(io_entity_t *entity, uintptr_t buffer,
local_length, length_read);
/* Adding part of size already read from header */
- *length_read += MAX_LBA_SIZE - sizeof(boot_api_image_header_t);
+ *length_read += MAX_LBA_SIZE - hdr_sz;
if (result != 0) {
ERROR("%s: io_read (%i)\n", __func__, result);