public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RFC][PATCH] bootcount: add support to customize bootcount variable name
@ 2019-09-09 13:56 Philippe Reynes
  2019-09-09 16:06 ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Reynes @ 2019-09-09 13:56 UTC (permalink / raw)
  To: u-boot

This commit add an option to customize the bootcount variable
name in the u-boot environment. To stay compatible with old config,
the default name is bootcount.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
 drivers/bootcount/Kconfig         | 8 ++++++++
 drivers/bootcount/bootcount_env.c | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig
index b7c29f2..0088bf8 100644
--- a/drivers/bootcount/Kconfig
+++ b/drivers/bootcount/Kconfig
@@ -161,4 +161,12 @@ config SYS_BOOTCOUNT_MAGIC
 	help
 	  Set the magic value used for the boot counter.
 
+config SYS_BOOTCOUNT_NAME
+	string "Name of the bootcount variable in the env"
+	default "bootcount"
+	depends on BOOTCOUNT_ENV
+	help
+	  Set the name of the variable that count the number of boot.
+	  Usually this variable is named 'bootcount'.
+
 endif
diff --git a/drivers/bootcount/bootcount_env.c b/drivers/bootcount/bootcount_env.c
index b75c900..d5a38c8 100644
--- a/drivers/bootcount/bootcount_env.c
+++ b/drivers/bootcount/bootcount_env.c
@@ -12,7 +12,7 @@ void bootcount_store(ulong a)
 	int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
 
 	if (upgrade_available) {
-		env_set_ulong("bootcount", a);
+		env_set_ulong(CONFIG_SYS_BOOTCOUNT_NAME, a);
 		env_save();
 	}
 }
@@ -23,7 +23,7 @@ ulong bootcount_load(void)
 	ulong val = 0;
 
 	if (upgrade_available)
-		val = env_get_ulong("bootcount", 10, 0);
+		val = env_get_ulong(CONFIG_SYS_BOOTCOUNT_NAME, 10, 0);
 
 	return val;
 }
-- 
2.7.4

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

end of thread, other threads:[~2019-09-10  8:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-09 13:56 [U-Boot] [RFC][PATCH] bootcount: add support to customize bootcount variable name Philippe Reynes
2019-09-09 16:06 ` Wolfgang Denk
2019-09-09 16:41   ` Philippe REYNES
2019-09-10  8:23     ` Wolfgang Denk

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