[U-Boot] [RFC][PATCH] bootcount: add support to customize bootcount variable name

Philippe Reynes philippe.reynes at softathome.com
Mon Sep 9 13:56:53 UTC 2019


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 at 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



More information about the U-Boot mailing list