mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] Kconfig: Make GLOBALVAR visible
@ 2016-04-27  8:38 Sascha Hauer
  2016-04-27  8:38 ` [PATCH 2/3] Kconfig: Make ENV_HANDLING visible Sascha Hauer
  2016-04-27  8:38 ` [PATCH 3/3] Kconfig: Create Kconfig symbol for NVVAR Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2016-04-27  8:38 UTC (permalink / raw)
  To: Barebox List

Currently global environment variables are only enabled when the
"global" command is enabled. In fact, they could be used even with
the "global" command disabled, so make the GLOBALVAR option visible.
While at it, add a help text for this option.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/Kconfig |  5 ++---
 common/Kconfig   | 12 +++++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 875c5f4..39a2df5 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -348,7 +348,7 @@ config CMD_BOOTM
 	select UIMAGE
 	select UNCOMPRESS
 	select FILETYPE
-	select GLOBALVAR
+	depends on GLOBALVAR
 	prompt "bootm"
 	help
 	  Boot an application image
@@ -741,13 +741,12 @@ config CMD_EXPORT
 
 config CMD_DEFAULTENV
 	tristate
-	select ENV_HANDLING
 	prompt "defaultenv"
 	help
 	  restore environment from default environment
 
 config CMD_GLOBAL
-	select GLOBALVAR
+	depends on GLOBALVAR
 	tristate
 	prompt "global"
 	help
diff --git a/common/Kconfig b/common/Kconfig
index 7c09e8c..503f43a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -78,9 +78,6 @@ config FITIMAGE_SIGNATURE
 config LOGBUF
 	bool
 
-config GLOBALVAR
-	bool
-
 config STDDEV
 	bool
 
@@ -159,6 +156,15 @@ config MEMINFO
 config ENVIRONMENT_VARIABLES
 	bool "environment variables support"
 
+config GLOBALVAR
+	bool "global environment variables support"
+	default y if !SHELL_NONE
+	help
+	  Global environment variables begin with "global.". Unlike normal
+	  shell variables they have the same values in all contexts. Global
+	  variables are used to control several aspects of the system behaviour.
+	  If unsure, say yes here.
+
 menu "memory layout"
 
 source "pbl/Kconfig"
-- 
2.8.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] Kconfig: Make ENV_HANDLING visible
  2016-04-27  8:38 [PATCH 1/3] Kconfig: Make GLOBALVAR visible Sascha Hauer
@ 2016-04-27  8:38 ` Sascha Hauer
  2016-04-27  8:38 ` [PATCH 3/3] Kconfig: Create Kconfig symbol for NVVAR Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2016-04-27  8:38 UTC (permalink / raw)
  To: Barebox List

ENV_HANDLING is usable even without explicit loadenv/saveenv command
support. Instead of selecting this option from loadenv/saveenv, make
this option visible. loadenv/saveenv can then depend on ENV_HANDLING
rather than selecting it. This reduces Kconfig dependencies hassles.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/Kconfig |  4 ++--
 common/Kconfig   | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 39a2df5..56b9542 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -761,7 +761,7 @@ config CMD_GLOBAL
 
 config CMD_LOADENV
 	tristate
-	select ENV_HANDLING
+	depends on ENV_HANDLING
 	prompt "loadenv"
 	help
 	  Load environment from ENVFS
@@ -805,7 +805,7 @@ config CMD_MAGICVAR_HELP
 
 config CMD_SAVEENV
 	tristate
-	select ENV_HANDLING
+	depends on ENV_HANDLING
 	prompt "saveenv"
 	help
 	  Save environment to persistent storage
diff --git a/common/Kconfig b/common/Kconfig
index 503f43a..12f6e84 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -21,10 +21,6 @@ config HAS_KALLSYMS
 config HAS_MODULES
 	bool
 
-config ENV_HANDLING
-	select CRC32
-	bool
-
 config HAS_CACHE
 	bool
 	help
@@ -646,10 +642,20 @@ config PARTITION
 
 source common/partitions/Kconfig
 
+config ENV_HANDLING
+	select CRC32
+	bool "Support environment files storage"
+	default y if !SHELL_NONE
+	help
+	  Enabling this option will give you environment files which can be stored
+	  over reboots. The "saveenv" command will store all files under /env/ to
+	  the persistent environment, the "loadenv" command (also executed during
+	  startup) will bring them back. If unsure, say yes.
+
 config DEFAULT_ENVIRONMENT
 	bool
 	default y
-	select ENV_HANDLING
+	depends on ENV_HANDLING
 	prompt "Compile in default environment"
 	help
 	  Enabling this option will give you a default environment when
-- 
2.8.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] Kconfig: Create Kconfig symbol for NVVAR
  2016-04-27  8:38 [PATCH 1/3] Kconfig: Make GLOBALVAR visible Sascha Hauer
  2016-04-27  8:38 ` [PATCH 2/3] Kconfig: Make ENV_HANDLING visible Sascha Hauer
@ 2016-04-27  8:38 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2016-04-27  8:38 UTC (permalink / raw)
  To: Barebox List

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>
---
 commands/Kconfig   |  2 +-
 common/Kconfig     | 15 +++++++++++++++
 common/globalvar.c | 18 ++++++++++++++++--
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 56b9542..0aab6ef 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 12f6e84..75e94d6 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 9a793ac..a777c14 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);
 
-- 
2.8.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-27  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-27  8:38 [PATCH 1/3] Kconfig: Make GLOBALVAR visible Sascha Hauer
2016-04-27  8:38 ` [PATCH 2/3] Kconfig: Make ENV_HANDLING visible Sascha Hauer
2016-04-27  8:38 ` [PATCH 3/3] Kconfig: Create Kconfig symbol for NVVAR Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox