summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-26 11:18:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-28 16:43:15 +0200
commitacd643788b6f7d7c26ebdb00a39dba3338ebfcee (patch)
treed2de2da8b9e7e6c3bf002132f7e496bafa9ca73d
parent9a7b5d4cdc975f15344c207f9972b2a25b874daf (diff)
downloadbarebox-acd643788b6f7d7c26ebdb00a39dba3338ebfcee.tar.gz
barebox-acd643788b6f7d7c26ebdb00a39dba3338ebfcee.tar.xz
Kconfig: Create Kconfig symbol for NVVAR
nvvar support not only needs globalvar, but also persistent environment storage. Add a separate default-y option which depends on ENV_HANDLING for this case. Make the option visible to let the user decide whether he wants to have this option and add a help text to make this decision easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--commands/Kconfig2
-rw-r--r--common/Kconfig15
-rw-r--r--common/globalvar.c18
3 files changed, 32 insertions, 3 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 56b95425c0..0aab6effea 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -715,7 +715,7 @@ endmenu
menu "Environment"
config CMD_NV
- select GLOBALVAR
+ depends on NVVAR
tristate
prompt "nv"
help
diff --git a/common/Kconfig b/common/Kconfig
index a37141e3c7..fdf2f0da13 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -161,6 +161,21 @@ config GLOBALVAR
variables are used to control several aspects of the system behaviour.
If unsure, say yes here.
+config NVVAR
+ bool "Non volatile global environment variables support"
+ default y if !SHELL_NONE
+ depends on GLOBALVAR
+ depends on ENV_HANDLING
+ help
+ Non volatile environment variables begin with "nv.". They behave like
+ global variables above, but their values are saved in the environment
+ storage with 'saveenv' and thus are persistent over restarts. nv variables
+ are coupled with global variables of the same name. Setting "nv.foo" results
+ in "global.foo" changed also (but not the other way round: setting "global.foo"
+ leaves "nv.foo" untouched). The idea is that nv variables can store defaults
+ while global variables can be changed during runtime without changing the
+ default.
+
menu "memory layout"
source "pbl/Kconfig"
diff --git a/common/globalvar.c b/common/globalvar.c
index 9a793ac4a9..a777c14283 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -90,6 +90,9 @@ int nvvar_add(const char *name, const char *value)
struct param_d *p, *gp;
int ret;
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return -ENOSYS;
+
gp = get_param_by_name(&nv_device, name);
if (gp) {
ret = dev_set_param(&global_device, name, value);
@@ -131,6 +134,9 @@ int nvvar_remove(const char *name)
struct param_d *p;
char *fname;
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return -ENOSYS;
+
p = get_param_by_name(&nv_device, name);
if (!p)
return -ENOENT;
@@ -153,6 +159,9 @@ int nvvar_load(void)
DIR *dir;
struct dirent *d;
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return -ENOSYS;
+
dir = opendir("/env/nv");
if (!dir)
return -ENOENT;
@@ -185,7 +194,7 @@ static void device_param_print(struct device_d *dev)
const char *p = dev_get_param(dev, param->name);
const char *nv = NULL;
- if (dev != &nv_device)
+ if (IS_ENABLED(CONFIG_NVVAR) && dev != &nv_device)
nv = dev_get_param(&nv_device, param->name);
printf("%s%s: %s\n", nv ? "* " : " ", param->name, p);
@@ -194,6 +203,9 @@ static void device_param_print(struct device_d *dev)
void nvvar_print(void)
{
+ if (!IS_ENABLED(CONFIG_NVVAR))
+ return;
+
device_param_print(&nv_device);
}
@@ -264,7 +276,9 @@ int globalvar_add_simple(const char *name, const char *value)
static int globalvar_init(void)
{
register_device(&global_device);
- register_device(&nv_device);
+
+ if (IS_ENABLED(CONFIG_NVVAR))
+ register_device(&nv_device);
globalvar_add_simple("version", UTS_RELEASE);