summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNora Schiffer <[email protected]>2026-04-07 15:06:46 +0200
committerFabio Estevam <[email protected]>2026-04-21 20:49:39 -0300
commit9f1807e57cbbba22e93e1580fc54e3ac8a3b745d (patch)
treef78fe0adfe71e1dcf3e4e4358e4d62d06050079c
parentc8eebe0a707b1105cb49ec523c1ffe41c0185cd8 (diff)
env: add env_set_runtime() helper
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 <[email protected]> Signed-off-by: Steffen Doster <[email protected]> Signed-off-by: Max Merchel <[email protected]> Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Alexander Feilke <[email protected]>
-rw-r--r--include/env.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/env.h b/include/env.h
index 01c3eeae7e2..9b872fb26eb 100644
--- a/include/env.h
+++ b/include/env.h
@@ -9,6 +9,7 @@
#ifndef __ENV_H
#define __ENV_H
+#include <config.h>
#include <compiler.h>
#include <stdbool.h>
#include <linux/types.h>
@@ -161,6 +162,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
*
* Most U-Boot environment variables store hex values. For those which store