All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 41/50] image: Drop unnecessary #ifdefs from image.h
Date: Thu,  6 May 2021 08:24:29 -0600	[thread overview]
Message-ID: <20210506142438.1310977-14-sjg@chromium.org> (raw)
In-Reply-To: <20210506142438.1310977-1-sjg@chromium.org>

This file has a lot of conditional code and much of it is unnecessary.
Clean this up to reduce the number of build combinations.

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

(no changes since v1)

 include/image.h                | 40 ++++------------------------------
 include/u-boot/hash-checksum.h |  5 +++--
 lib/hash-checksum.c            |  2 +-
 3 files changed, 8 insertions(+), 39 deletions(-)

diff --git a/include/image.h b/include/image.h
index d7e0c829841..a8b10a8fddb 100644
--- a/include/image.h
+++ b/include/image.h
@@ -39,12 +39,10 @@ struct fdt_region;
 
 #endif /* USE_HOSTCC */
 
-#if CONFIG_IS_ENABLED(FIT)
 #include <hash.h>
 #include <linux/libfdt.h>
 #include <fdt_support.h>
-
-#endif /* FIT */
+#include <u-boot/hash-checksum.h>
 
 extern ulong image_load_addr;		/* Default Load Address */
 extern ulong image_save_addr;		/* Default Save Address */
@@ -504,8 +502,7 @@ int genimg_get_type_id(const char *name);
 int genimg_get_comp_id(const char *name);
 void genimg_print_size(uint32_t size);
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || \
-	defined(USE_HOSTCC)
+#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
 #define IMAGE_ENABLE_TIMESTAMP 1
 #else
 #define IMAGE_ENABLE_TIMESTAMP 0
@@ -523,12 +520,9 @@ enum fit_load_op {
 int boot_get_setup(bootm_headers_t *images, uint8_t arch, ulong *setup_start,
 		   ulong *setup_len);
 
-#ifndef USE_HOSTCC
 /* Image format types, returned by _get_format() routine */
 #define IMAGE_FORMAT_INVALID	0x00
-#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
 #define IMAGE_FORMAT_LEGACY	0x01	/* legacy image_header based format */
-#endif
 #define IMAGE_FORMAT_FIT	0x02	/* new, libfdt based format */
 #define IMAGE_FORMAT_ANDROID	0x03	/* Android boot image */
 
@@ -567,7 +561,6 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
  */
 int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
 		      uint8_t arch, const ulong *ld_start, ulong *const ld_len);
-#endif /* !USE_HOSTCC */
 
 int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
 		       ulong *setup_start, ulong *setup_len);
@@ -644,7 +637,6 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
  */
 int image_source_script(ulong addr, const char *fit_uname);
 
-#ifndef USE_HOSTCC
 /**
  * fit_get_node_from_config() - Look up an image a FIT by type
  *
@@ -684,10 +676,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size);
 int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
 		  ulong *initrd_start, ulong *initrd_end);
 int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end);
-#ifdef CONFIG_SYS_BOOT_GET_KBD
 int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd);
-#endif /* CONFIG_SYS_BOOT_GET_KBD */
-#endif /* !USE_HOSTCC */
 
 /*******************************************************************/
 /* Legacy format specific code (prefixed with image_) */
@@ -802,11 +791,9 @@ static inline int image_check_type(const image_header_t *hdr, uint8_t type)
 }
 static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
 {
-#ifndef USE_HOSTCC
 	/* Let's assume that sandbox can load any architecture */
-	if (IS_ENABLED(CONFIG_SANDBOX))
+	if (!host_build() && IS_ENABLED(CONFIG_SANDBOX))
 		return true;
-#endif
 	return (image_get_arch(hdr) == arch) ||
 		(image_get_arch(hdr) == IH_ARCH_ARM && arch == IH_ARCH_ARM64);
 }
@@ -954,7 +941,6 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,
 
 #define FIT_MAX_HASH_LEN	HASH_MAX_DIGEST_SIZE
 
-#if CONFIG_IS_ENABLED(FIT)
 /* cmdline argument format parsing */
 int fit_parse_conf(const char *spec, ulong addr_curr,
 		ulong *addr, const char **conf_name);
@@ -1128,7 +1114,6 @@ int fit_conf_get_prop_node(const void *fit, int noffset,
 
 int fit_check_ramdisk(const void *fit, int os_noffset,
 		uint8_t arch, int verify);
-#endif /* FIT */
 
 int calculate_hash(const void *data, int data_len, const char *algo,
 			uint8_t *value, int *value_len);
@@ -1148,7 +1133,6 @@ int calculate_hash(const void *data, int data_len, const char *algo,
 # define IMAGE_ENABLE_VERIFY_ECDSA	0
 #endif
 
-#if CONFIG_IS_ENABLED(FIT)
 #ifdef USE_HOSTCC
 void *image_get_host_blob(void);
 void image_set_host_blob(void *host_blob);
@@ -1157,8 +1141,6 @@ void image_set_host_blob(void *host_blob);
 # define gd_fdt_blob()		(gd->fdt_blob)
 #endif
 
-#endif /* FIT */
-
 /*
  * Information passed to the signing routines
  *
@@ -1195,9 +1177,6 @@ struct image_region {
 	int size;
 };
 
-#if CONFIG_IS_ENABLED(RSA_VERIFY)
-# include <u-boot/hash-checksum.h>
-#endif
 struct checksum_algo {
 	const char *name;
 	const int checksum_len;
@@ -1207,7 +1186,7 @@ struct checksum_algo {
 	const EVP_MD *(*calculate_sign)(void);
 #endif
 	int (*calculate)(const char *name,
-			 const struct image_region region[],
+			 const struct image_region *region,
 			 int region_count, uint8_t *checksum);
 };
 
@@ -1295,8 +1274,6 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name);
  */
 struct padding_algo *image_get_padding_algo(const char *name);
 
-#if CONFIG_IS_ENABLED(FIT)
-
 /**
  * fit_image_verify_required_sigs() - Verify signatures marked as 'required'
  *
@@ -1412,10 +1389,6 @@ int fit_image_cipher_get_algo(const void *fit, int noffset, char **algo);
 
 struct cipher_algo *image_get_cipher_algo(const char *full_name);
 
-#endif /* CONFIG_FIT */
-
-#if !defined(USE_HOSTCC)
-#if defined(CONFIG_ANDROID_BOOT_IMAGE)
 struct andr_img_hdr;
 int android_image_check_header(const struct andr_img_hdr *hdr);
 int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
@@ -1431,12 +1404,7 @@ ulong android_image_get_end(const struct andr_img_hdr *hdr);
 ulong android_image_get_kload(const struct andr_img_hdr *hdr);
 ulong android_image_get_kcomp(const struct andr_img_hdr *hdr);
 void android_print_contents(const struct andr_img_hdr *hdr);
-#if !defined(CONFIG_SPL_BUILD)
 bool android_image_print_dtb_contents(ulong hdr_addr);
-#endif
-
-#endif /* CONFIG_ANDROID_BOOT_IMAGE */
-#endif /* !USE_HOSTCC */
 
 /**
  * board_fit_config_name_match() - Check for a matching board name
diff --git a/include/u-boot/hash-checksum.h b/include/u-boot/hash-checksum.h
index 54e6a73744e..7f16b37a9ab 100644
--- a/include/u-boot/hash-checksum.h
+++ b/include/u-boot/hash-checksum.h
@@ -7,11 +7,12 @@
 #define _RSA_CHECKSUM_H
 
 #include <errno.h>
-#include <image.h>
 #include <u-boot/sha1.h>
 #include <u-boot/sha256.h>
 #include <u-boot/sha512.h>
 
+struct image_region;
+
 /**
  * hash_calculate() - Calculate hash over the data
  *
@@ -23,7 +24,7 @@
  * @return 0 if OK, < 0 if error
  */
 int hash_calculate(const char *name,
-		   const struct image_region region[], int region_count,
+		   const struct image_region *region, int region_count,
 		   uint8_t *checksum);
 
 #endif
diff --git a/lib/hash-checksum.c b/lib/hash-checksum.c
index d732ecc38fd..8f2a42f9a08 100644
--- a/lib/hash-checksum.c
+++ b/lib/hash-checksum.c
@@ -17,7 +17,7 @@
 #include <image.h>
 
 int hash_calculate(const char *name,
-		    const struct image_region region[],
+		    const struct image_region *region,
 		    int region_count, uint8_t *checksum)
 {
 	struct hash_algo *algo;
-- 
2.31.1.607.g51e8a6a459-goog

  parent reply	other threads:[~2021-05-06 14:24 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 14:23 [PATCH v2 00/50] image: Reduce #ifdefs and ad-hoc defines in image code Simon Glass
2021-05-06 14:23 ` [PATCH v2 01/50] lib: Add memdup() Simon Glass
2021-05-06 17:07   ` Pratyush Yadav
2021-05-06 17:41     ` Simon Glass
2021-05-06 17:57       ` Sean Anderson
2021-05-10  9:00       ` Rasmus Villemoes
2021-05-10 11:21         ` Heinrich Schuchardt
2021-05-10 16:28         ` Simon Glass
2021-05-06 14:23 ` [PATCH v2 02/50] Add support for an owned buffer Simon Glass
2021-05-06 14:23 ` [PATCH v2 03/50] compiler: Add a comment to host_build() Simon Glass
2021-05-06 14:23 ` [PATCH v2 04/50] zstd: Create a function for use from U-Boot Simon Glass
2021-05-06 14:23 ` [PATCH v2 05/50] btrfs: Use U-Boot API for decompression Simon Glass
2021-05-06 14:23 ` [PATCH v2 06/50] image: Avoid switch default in image_decomp() Simon Glass
2021-05-06 14:23 ` [PATCH v2 07/50] image: Update zstd to avoid reporting error twice Simon Glass
2021-05-06 14:23 ` [PATCH v2 08/50] gzip: Avoid use of u64 Simon Glass
2021-05-06 14:23 ` [PATCH v2 09/50] image: Update image_decomp() to avoid ifdefs Simon Glass
2021-05-06 14:23 ` [PATCH v2 10/50] image: Split board code out into its own file Simon Glass
2021-05-06 14:23 ` [PATCH v2 11/50] image: Fix up checkpatch warnings in image-board.c Simon Glass
2021-05-06 14:24 ` [PATCH v2 12/50] image: Split host code out into its own file Simon Glass
2021-05-06 14:24 ` [PATCH v2 13/50] image: Create a function to do manual relocation Simon Glass
2021-05-06 14:24 ` [PATCH v2 14/50] image: Avoid #ifdefs for " Simon Glass
2021-05-06 14:24 ` [PATCH v2 15/50] image: Remove ifdefs around image_setup_linux() el at Simon Glass
2021-05-06 14:24 ` [PATCH v2 16/50] image: Add Kconfig options for FIT in the host build Simon Glass
2021-05-11 19:57   ` Alex G.
2021-05-11 22:34     ` Tom Rini
2021-05-12  0:50       ` Alex G.
2021-05-12  1:10         ` Tom Rini
2021-05-12 15:52           ` Simon Glass
2021-05-12 16:19             ` Alex G.
2021-05-12 17:14               ` Tom Rini
2021-05-17 22:29                 ` Alex G.
2021-05-18  1:23                   ` AKASHI Takahiro
2021-05-19 15:49                     ` Alex G
2021-05-12 14:51     ` Simon Glass
2021-05-12 15:48       ` Alex G.
2021-05-12 15:54         ` Simon Glass
2021-05-12 16:18           ` Alex G.
2021-05-12 17:30             ` Simon Glass
2021-05-13 16:21               ` Alex G.
2021-05-13 23:56                 ` Simon Glass
2021-05-14 15:12                   ` Alex G.
2021-05-15 15:20                     ` Simon Glass
2021-05-06 14:24 ` [PATCH v2 17/50] kconfig: Add host support to CONFIG_IS_ENABLED() Simon Glass
2021-05-06 14:24 ` [PATCH v2 18/50] image: Shorten FIT_ENABLE_SHAxxx_SUPPORT Simon Glass
2021-05-14 15:30   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 19/50] image: Rename SPL_SHAxxx_SUPPORT to SPL_FIT_SHAxxx Simon Glass
2021-05-14 15:34   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 20/50] hash: Use Kconfig to enable hashing in host tools Simon Glass
2021-05-06 14:24 ` [PATCH v2 21/50] hash: Drop some #ifdefs in hash.c Simon Glass
2021-05-14 15:37   ` Alex G.
2021-05-14 20:43     ` Tom Rini
2021-05-06 14:24 ` [PATCH v2 22/50] image: Drop IMAGE_ENABLE_FIT Simon Glass
2021-05-06 14:24 ` [PATCH v2 23/50] image: Drop IMAGE_ENABLE_OF_LIBFDT Simon Glass
2021-05-06 14:24 ` [PATCH v2 24/50] image: Use Kconfig to enable CONFIG_FIT_VERBOSE on host Simon Glass
2021-05-06 14:24 ` [PATCH v2 25/50] image: Rename CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT Simon Glass
2021-05-06 14:24 ` [PATCH v2 26/50] image: Use Kconfig to enable FIT_RSASSA_PSS on host Simon Glass
2021-05-06 14:24 ` [PATCH v2 27/50] Kconfig: Rename SPL_CRC32_SUPPORT to SPL_CRC32 Simon Glass
2021-05-14 21:31   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 28/50] image: Drop IMAGE_ENABLE_CRC32 Simon Glass
2021-05-06 14:24 ` [PATCH v2 29/50] Kconfig: Rename SPL_MD5_SUPPORT to SPL_MD5 Simon Glass
2021-05-14 21:31   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 30/50] image: Drop IMAGE_ENABLE_MD5 Simon Glass
2021-05-06 14:24 ` [PATCH v2 31/50] image: Drop IMAGE_ENABLE_SHA1 Simon Glass
2021-05-06 14:24 ` [PATCH v2 32/50] image: Drop IMAGE_ENABLE_SHAxxx Simon Glass
2021-05-06 14:24 ` [PATCH v2 33/50] image: Drop IMAGE_BOOT_GET_CMDLINE Simon Glass
2021-05-06 14:24 ` [PATCH v2 34/50] image: Drop IMAGE_OF_BOARD_SETUP Simon Glass
2021-05-06 14:24 ` [PATCH v2 35/50] image: Drop IMAGE_OF_SYSTEM_SETUP Simon Glass
2021-05-06 14:24 ` [PATCH v2 36/50] image: Drop IMAGE_ENABLE_IGNORE Simon Glass
2021-05-06 14:24 ` [PATCH v2 37/50] image: Drop IMAGE_ENABLE_SIGN/VERIFY defines Simon Glass
2021-05-14 20:38   ` Alex G.
2021-05-14 20:44     ` Simon Glass
2021-05-14 21:17       ` Alex G.
2021-05-15 15:20         ` Simon Glass
2021-05-06 14:24 ` [PATCH v2 38/50] image: Drop IMAGE_ENABLE_BEST_MATCH Simon Glass
2021-05-14 21:32   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 39/50] image: Drop IMAGE_ENABLE_EN/DECRYPT defines Simon Glass
2021-05-06 14:24 ` [PATCH v2 40/50] image: Tidy up fit_unsupported_reset() Simon Glass
2021-05-06 14:24 ` Simon Glass [this message]
2021-05-14 21:45   ` [PATCH v2 41/50] image: Drop unnecessary #ifdefs from image.h Alex G.
2021-05-06 14:24 ` [PATCH v2 42/50] image: Drop #ifdefs for fit_print_contents() Simon Glass
2021-05-14 21:46   ` Alex G.
2021-05-06 14:24 ` [PATCH v2 43/50] image: Drop most #ifdefs in image-board.c Simon Glass
2021-05-06 14:24 ` [PATCH v2 44/50] image: Reduce variable scope in boot_get_ramdisk() Simon Glass
2021-05-06 14:24 ` [PATCH v2 45/50] image: Split up boot_get_ramdisk() Simon Glass
2021-05-06 14:24 ` [PATCH v2 46/50] image: Remove #ifdefs from select_ramdisk() Simon Glass
2021-05-06 14:24 ` [PATCH v2 47/50] image: Remove some #ifdefs from image-fit and image-fit-sig Simon Glass
2021-05-14 21:50   ` Alex G.
2021-05-15 15:20     ` Simon Glass
2021-05-06 14:24 ` [PATCH v2 48/50] image: Reduce variable scope in boot_get_fdt() Simon Glass
2021-05-06 14:24 ` [PATCH v2 49/50] image: Split up boot_get_fdt() Simon Glass
2021-05-06 14:24 ` [PATCH v2 50/50] image: Remove #ifdefs from select_fdt() Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210506142438.1310977-14-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.