Skip to contentSkip to conversation

env: Add CONFIG_ENV_SUPPORT

PATCH New Patrick Delaunay 2 participants 2 messages Sep 6, 2019 – Sep 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 env: Add CONFIG_ENV_SUPPORT

Add a new flag CONFIG_ENV_SUPPORT to compile all the environment features in U-Boot (attributes, callbacks and flags); it is the supplement of the 2 existing flags for SPL/TPL.
To have ENV support, enable the flag:
- CONFIG_ENV_SUPPORT for U-Boot proper
- CONFIG_SPL_ENV_SUPPORT for SPL
- CONFIG_TPL_ENV_SUPPORT for TPL

This new configuration allows to use the macro CONFIG_IS_ENABLED(ENV_SUPPORT) in the code without issue and solves the regression introduced by commit 7d4776545b0f ("env: solve compilation error in SPL"); change_ok was always NULL in U-Boot.

---

Changes in v2:
- Update commit message after Lukasz Majewki review

 cmd/Kconfig            |  2 ++
 env/Kconfig            |  7 +++++++
 env/Makefile           | 11 ++++-------
 include/env_callback.h |  4 ++++
 include/env_flags.h    |  4 ++++
 5 files changed, 21 insertions(+), 7 deletions(-)
cmd/Kconfig +2 -0
index 05872fa0d7..f7a1b1faf5 100644
@@ -465,6 +465,7 @@ config CMD_ENV_EXISTS
 
 config CMD_ENV_CALLBACK
 	bool "env callbacks - print callbacks and their associated variables"
+	depends on ENV_SUPPORT
 	help
 	  Some environment variable have callbacks defined by
 	  U_BOOT_ENV_CALLBACK. These are called when the variable changes.
@@ -473,6 +474,7 @@ config CMD_ENV_CALLBACK
 
 config CMD_ENV_FLAGS
 	bool "env flags -print variables that have non-default flags"
+	depends on ENV_SUPPORT
 	help
 	  Some environment variables have special flags that control their
 	  behaviour. For example, serial# can only be written once and cannot
env/Kconfig +7 -0
index 74db2f38cc..f0c5a7a39c 100644
@@ -1,5 +1,12 @@
 menu "Environment"
 
+config ENV_SUPPORT
+	bool "Support all environment features"
+	default y
+	help
+	  Enable full environment support in U-Boot,
+	  including attributes, callbacks and flags.
+
 config ENV_IS_NOWHERE
 	bool "Environment is not stored"
 	default y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \
env/Makefile +4 -7
index 90144d6caf..2a468ac16b 100644
@@ -5,10 +5,11 @@
 
 obj-y += common.o env.o
 
+obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += attr.o
+obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += flags.o
+obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += callback.o
+
 ifndef CONFIG_SPL_BUILD
-obj-y += attr.o
-obj-y += callback.o
-obj-y += flags.o
 obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
 extra-$(CONFIG_ENV_IS_EMBEDDED) += embedded.o
 obj-$(CONFIG_ENV_IS_IN_EEPROM) += embedded.o
@@ -19,10 +20,6 @@ obj-$(CONFIG_ENV_IS_IN_ONENAND) += onenand.o
 obj-$(CONFIG_ENV_IS_IN_SATA) += sata.o
 obj-$(CONFIG_ENV_IS_IN_REMOTE) += remote.o
 obj-$(CONFIG_ENV_IS_IN_UBI) += ubi.o
-else
-obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += attr.o
-obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += flags.o
-obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += callback.o
 endif
 
 obj-$(CONFIG_$(SPL_TPL_)ENV_IS_NOWHERE) += nowhere.o
include/env_callback.h +4 -0
index 982c07854d..a757fe6b5f 100644
@@ -72,6 +72,10 @@
 	"serial#:serialno," \
 	CONFIG_ENV_CALLBACK_LIST_STATIC
 
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
 void env_callback_init(struct env_entry *var_entry);
+#else
+static inline void env_callback_init(struct env_entry *var_entry) { }
+#endif
 
 #endif /* __ENV_CALLBACK_H__ */
include/env_flags.h +4 -0
index e5380f2948..ec480e3ed7 100644
@@ -153,7 +153,11 @@ int env_flags_validate_env_set_params(char *name, char *const val[], int count);
  * When adding a variable to the environment, initialize the flags for that
  * variable.
  */
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
 void env_flags_init(struct env_entry *var_entry);
+#else
+static inline void env_flags_init(struct env_entry *var_entry) { }
+#endif
 
 /*
  * Validate the newval for to conform with the requirements defined by its flags
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 env: Add CONFIG_ENV_SUPPORT

Quoted 22 lines · Patrick Delaunay

Add a new flag CONFIG_ENV_SUPPORT to compile all the environment features in U-Boot (attributes, callbacks and flags); it is the supplement of the 2 existing flags for SPL/TPL.
To have ENV support, enable the flag:
- CONFIG_ENV_SUPPORT for U-Boot proper
- CONFIG_SPL_ENV_SUPPORT for SPL
- CONFIG_TPL_ENV_SUPPORT for TPL

This new configuration allows to use the macro CONFIG_IS_ENABLED(ENV_SUPPORT) in the code without issue and solves the regression introduced by commit 7d4776545b0f ("env: solve compilation error in SPL"); change_ok was always NULL in U-Boot.

---

Changes in v2:
- Update commit message after Lukasz Majewki review

Quoted 6 lines
 cmd/Kconfig            |  2 ++
 env/Kconfig            |  7 +++++++
 env/Makefile           | 11 ++++-------
 include/env_callback.h |  4 ++++
 include/env_flags.h    |  4 ++++
 5 files changed, 21 insertions(+), 7 deletions(-)