[PATCH v2 16/35] global_data: Use less space for environment fields

Simon Glass sjg at chromium.org
Wed Aug 21 18:19:08 CEST 2024


Use shorter types for some of these fields to save space. Reorder to put
fields with like alignment together.

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

(no changes since v1)

 include/asm-generic/global_data.h | 14 +++++++-------
 include/env_internal.h            |  1 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 86e8d654a28..1252b8acefa 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -114,21 +114,21 @@ struct global_data {
 	 */
 	unsigned long env_addr;
 	/**
-	 * @env_valid: environment is valid
+	 * @env_has_init: bit mask indicating environment locations
 	 *
-	 * See &enum env_valid
+	 * &enum env_location defines which bit relates to which location
 	 */
-	unsigned long env_valid;
+	unsigned short env_has_init;
 	/**
-	 * @env_has_init: bit mask indicating environment locations
+	 * @env_valid: environment is valid
 	 *
-	 * &enum env_location defines which bit relates to which location
+	 * See &enum env_valid
 	 */
-	unsigned long env_has_init;
+	unsigned char env_valid;
 	/**
 	 * @env_load_prio: priority of the loaded environment
 	 */
-	int env_load_prio;
+	char env_load_prio;
 	/**
 	 * @ram_base: base address of RAM used by U-Boot
 	 */
diff --git a/include/env_internal.h b/include/env_internal.h
index 0a267e35592..c1c0727e4d0 100644
--- a/include/env_internal.h
+++ b/include/env_internal.h
@@ -100,6 +100,7 @@ extern const char default_environment[];
 #include <env_flags.h>
 #include <search.h>
 
+/* this is stored as bits in gd->env_has_init so is limited to 16 entries */
 enum env_location {
 	ENVL_UNKNOWN,
 	ENVL_EEPROM,
-- 
2.34.1



More information about the U-Boot mailing list