[PATCH 3/8] image: Drop #ifdefs for LEGACY_IMAGE_FORMAT

Simon Glass sjg at chromium.org
Sun Aug 28 20:32:48 CEST 2022


Use if() instead of the #ifdef in select_ramdisk().

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 boot/image-board.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/boot/image-board.c b/boot/image-board.c
index 2d5e5b6e6f0..a80ad08b15f 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -24,7 +24,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**
  * image_get_ramdisk - get and verify ramdisk image
  * @rd_addr: ramdisk image start address
@@ -83,7 +82,6 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, u8 arch,
 
 	return rd_hdr;
 }
-#endif
 
 /*****************************************************************************/
 /* Shared dual-format routines */
@@ -386,26 +384,25 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
 		 */
 		buf = map_sysmem(rd_addr, 0);
 		switch (genimg_get_format(buf)) {
-#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
-		case IMAGE_FORMAT_LEGACY: {
-			const image_header_t *rd_hdr;
+		case IMAGE_FORMAT_LEGACY:
+			if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
+				const image_header_t *rd_hdr;
 
-			printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n",
-			       rd_addr);
+				printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n",
+				       rd_addr);
 
-			bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK);
-			rd_hdr = image_get_ramdisk(rd_addr, arch,
-						   images->verify);
+				bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK);
+				rd_hdr = image_get_ramdisk(rd_addr, arch,
+							   images->verify);
 
-			if (!rd_hdr)
-				return -ENOENT;
+				if (!rd_hdr)
+					return -ENOENT;
 
-			*rd_datap = image_get_data(rd_hdr);
-			*rd_lenp = image_get_data_size(rd_hdr);
-			done = true;
+				*rd_datap = image_get_data(rd_hdr);
+				*rd_lenp = image_get_data_size(rd_hdr);
+				done = true;
+			}
 			break;
-		}
-#endif
 #if CONFIG_IS_ENABLED(FIT)
 		case IMAGE_FORMAT_FIT:
 			rd_noffset = fit_image_load(images,
-- 
2.37.2.672.g94769d06f0-goog



More information about the U-Boot mailing list