[U-Boot] [PATCH v2] env: Add CONFIG_ENV_SUPPORT
Patrick Delaunay
patrick.delaunay at st.com
Fri Sep 6 07:06:11 UTC 2019
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.
Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
---
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(-)
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 05872fa0d7..f7a1b1faf5 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -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
diff --git a/env/Kconfig b/env/Kconfig
index 74db2f38cc..f0c5a7a39c 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -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 && \
diff --git a/env/Makefile b/env/Makefile
index 90144d6caf..2a468ac16b 100644
--- a/env/Makefile
+++ b/env/Makefile
@@ -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
diff --git a/include/env_callback.h b/include/env_callback.h
index 982c07854d..a757fe6b5f 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -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__ */
diff --git a/include/env_flags.h b/include/env_flags.h
index e5380f2948..ec480e3ed7 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -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
--
2.17.1
More information about the U-Boot
mailing list