@@ -285,7 +285,7 @@ static void
285285bs_list (struct boot_loader_state * state , char * buf , int len )
286286{
287287 struct image_header hdr ;
288- uint32_t slot , area_id ;
288+ uint32_t slot ;
289289 const struct flash_area * fap ;
290290 uint8_t image_index ;
291291#ifdef MCUBOOT_SERIAL_IMG_GRP_HASH
@@ -319,8 +319,8 @@ bs_list(struct boot_loader_state *state, char *buf, int len)
319319 uint32_t start_off = 0 ;
320320#endif
321321
322- area_id = flash_area_id_from_multi_image_slot ( image_index , slot );
323- if (flash_area_open ( area_id , & fap ) ) {
322+ fap = BOOT_IMG_AREA ( state , slot );
323+ if (fap == NULL ) {
324324 continue ;
325325 }
326326
@@ -333,7 +333,6 @@ bs_list(struct boot_loader_state *state, char *buf, int len)
333333
334334 if ((rc != 0 && rc != - ENOMEM ) ||
335335 num_sectors != SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN ) {
336- flash_area_close (fap );
337336 continue ;
338337 }
339338
@@ -395,7 +394,6 @@ bs_list(struct boot_loader_state *state, char *buf, int len)
395394 }
396395
397396 if (FIH_NOT_EQ (fih_rc , FIH_SUCCESS )) {
398- flash_area_close (fap );
399397 continue ;
400398 }
401399
@@ -408,7 +406,6 @@ bs_list(struct boot_loader_state *state, char *buf, int len)
408406#endif
409407#endif
410408
411- flash_area_close (fap );
412409 zcbor_map_start_encode (cbor_state , 20 );
413410
414411#if (BOOT_IMAGE_NUMBER > 1 )
@@ -555,7 +552,6 @@ bs_set(struct boot_loader_state *state, char *buf, int len)
555552
556553 for (slot = 0 ; slot < BOOT_NUM_SLOTS ; slot ++ ) {
557554 struct image_header hdr ;
558- uint32_t area_id ;
559555 const struct flash_area * fap ;
560556 uint8_t tmpbuf [64 ];
561557
@@ -565,9 +561,8 @@ bs_set(struct boot_loader_state *state, char *buf, int len)
565561 uint32_t start_off = 0 ;
566562#endif
567563
568- area_id = flash_area_id_from_multi_image_slot (image_index , slot );
569- if (flash_area_open (area_id , & fap )) {
570- BOOT_LOG_ERR ("Failed to open flash area ID %d" , area_id );
564+ fap = BOOT_IMG_AREA (state , slot );
565+ if (fap == NULL ) {
571566 continue ;
572567 }
573568
@@ -577,7 +572,6 @@ bs_set(struct boot_loader_state *state, char *buf, int len)
577572
578573 if ((rc != 0 && rc != - ENOMEM ) ||
579574 num_sectors != SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN ) {
580- flash_area_close (fap );
581575 continue ;
582576 }
583577
@@ -641,8 +635,6 @@ bs_set(struct boot_loader_state *state, char *buf, int len)
641635 rc = boot_serial_get_hash (& hdr , fap , hash );
642636#endif
643637#endif
644- flash_area_close (fap );
645-
646638 if (rc == 0 && memcmp (hash , img_hash .value , sizeof (hash )) == 0 ) {
647639 /* Hash matches, set this slot for test or confirmation */
648640 found = true;
0 commit comments