]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
env: add env_set_runtime() helper
authorNora Schiffer <nora.schiffer@ew.tq-group.com>
Tue, 7 Apr 2026 13:06:46 +0000 (15:06 +0200)
committerFabio Estevam <festevam@gmail.com>
Tue, 21 Apr 2026 23:49:39 +0000 (20:49 -0300)
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@ew.tq-group.com>
Signed-off-by: Steffen Doster <Steffen.Doster@tq-group.com>
Signed-off-by: Max Merchel <Max.Merchel@ew.tq-group.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Alexander Feilke <alexander.feilke@ew.tq-group.com>
include/env.h

index 01c3eeae7e23c70f8566d02532ff061ba5dba345..9b872fb26ebc9751aa89667348b060e884213359 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef __ENV_H
 #define __ENV_H
 
+#include <config.h>
 #include <compiler.h>
 #include <stdbool.h>
 #include <linux/types.h>
@@ -160,6 +161,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
  *