[PATCH 3/8] env: add env_set_runtime() helper

Alexander Feilke Alexander.Feilke at ew.tq-group.com
Thu Mar 12 15:31:13 CET 2026


From: Nora Schiffer <nora.schiffer at ew.tq-group.com>

env_set_runtime() is equivalent to env_set(), but does nothing when
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG is unset.

Signed-off-by: Nora Schiffer <nora.schiffer at ew.tq-group.com>
Signed-off-by: Steffen Doster <Steffen.Doster at tq-group.com>
Signed-off-by: Max Merchel <Max.Merchel at ew.tq-group.com>
Signed-off-by: Alexander Feilke <alexander.feilke at ew.tq-group.com>
---
 include/env.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/env.h b/include/env.h
index 01c3eeae7e2..193aff8f23b 100644
--- a/include/env.h
+++ b/include/env.h
@@ -160,6 +160,25 @@ bool env_get_autostart(void);
  */
 int env_set(const char *varname, const char *value);
 
+/**
+ * env_set_runtime() - set an environment variable if
+ * CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG is set.
+ *
+ * This is equivalent to env_set(), but does nothing if
+ * CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG is unset.
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable, or NULL or "" to delete the variable
+ * @return 0 if OK or !CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG, 1 on error
+ */
+static inline int env_set_runtime(const char *varname, const char *value)
+{
+	if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
+		return env_set(varname, value);
+
+	return 0;
+}
+
 /**
  * env_get_ulong() - Return an environment variable as an integer value
  *
-- 
2.34.1



More information about the U-Boot mailing list