aboutsummaryrefslogtreecommitdiff
path: root/plat
diff options
context:
space:
mode:
authorHeyi Guo <guoheyi@linux.alibaba.com>2021-01-25 21:45:47 +0800
committerDavid Horstmann <david.horstmann@arm.com>2021-04-06 17:17:33 +0100
commitabe6ce1d1bfc0d888734491ceb21bb5bcf811a80 (patch)
tree32963a37c31fc6d14f1ab5fe88cb5ab83246501b /plat
parent47fe4c4fe22fa7df5e79867eb6a52e842e6abdb6 (diff)
downloadtrusted-firmware-a-abe6ce1d1bfc0d888734491ceb21bb5bcf811a80.tar.gz
plat/arm/arm_image_load: refine plat_add_sp_images_load_info
Refine the function plat_add_sp_images_load_info() by saving the previous node and only setting its next link when the current node is valid. This can reduce the check for the next node and simply the total logic. Signed-off-by: Heyi Guo <guoheyi@linux.alibaba.com> Change-Id: I4061428bf49ef0c3816ac22aaeb2e50315531f88
Diffstat (limited to 'plat')
-rw-r--r--plat/arm/common/arm_image_load.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/plat/arm/common/arm_image_load.c b/plat/arm/common/arm_image_load.c
index 11cb3b8397..ebf6dfff88 100644
--- a/plat/arm/common/arm_image_load.c
+++ b/plat/arm/common/arm_image_load.c
@@ -38,43 +38,36 @@ void plat_flush_next_bl_params(void)
******************************************************************************/
static void plat_add_sp_images_load_info(struct bl_load_info *load_info)
{
- bl_load_info_node_t *node_info = load_info->head;
- unsigned int index = 0;
+ bl_load_info_node_t *curr_node = load_info->head;
+ bl_load_info_node_t *prev_node;
- if (sp_mem_params_descs[index].image_id == 0) {
+ /* Shortcut for empty SP list */
+ if (sp_mem_params_descs[0].image_id == 0) {
ERROR("No Secure Partition Image available\n");
return;
}
/* Traverse through the bl images list */
do {
- node_info = node_info->next_load_info;
- } while (node_info->next_load_info != NULL);
+ curr_node = curr_node->next_load_info;
+ } while (curr_node->next_load_info != NULL);
- bl_load_info_node_t *sp_node =
- &sp_mem_params_descs[index].load_node_mem;
+ prev_node = curr_node;
- node_info->next_load_info = sp_node;
-
- for (; index < MAX_SP_IDS; index++) {
- /* Populate the image information */
- sp_node->image_id = sp_mem_params_descs[index].image_id;
- sp_node->image_info = &sp_mem_params_descs[index].image_info;
-
- if ((index + 1U) == MAX_SP_IDS) {
- INFO("Reached Max number of SPs\n");
+ for (unsigned int index = 0; index < MAX_SP_IDS; index++) {
+ if (sp_mem_params_descs[index].image_id == 0) {
return;
}
+ curr_node = &sp_mem_params_descs[index].load_node_mem;
+ /* Populate the image information */
+ curr_node->image_id = sp_mem_params_descs[index].image_id;
+ curr_node->image_info = &sp_mem_params_descs[index].image_info;
- if (sp_mem_params_descs[index + 1U].image_id == 0) {
- return;
- }
-
- sp_node->next_load_info =
- &sp_mem_params_descs[index + 1U].load_node_mem;
- sp_node = sp_node->next_load_info;
-
+ prev_node->next_load_info = curr_node;
+ prev_node = curr_node;
}
+
+ INFO("Reached Max number of SPs\n");
}
#endif