diff options
author | Lukasz Majewski <lukma@denx.de> | 2018-05-02 16:10:53 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-05-10 20:38:25 -0400 |
commit | bc8c440fa48eb9c514829da785271a95604edbcc (patch) | |
tree | 3f0cf0046360d36fa07ef246f2a8e36a002d07c1 | |
parent | 0da7041218f4779480177cd0f2f97ba2b4396e76 (diff) | |
download | u-boot-bc8c440fa48eb9c514829da785271a95604edbcc.zip u-boot-bc8c440fa48eb9c514829da785271a95604edbcc.tar.gz u-boot-bc8c440fa48eb9c514829da785271a95604edbcc.tar.bz2 |
bootcount: Rewrite autoboot to use wrapper functions from bootcount.h
The code has been refactored to use common wrappers from bootcount.h
header.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Alex Kiernan <alex.kiernan@gmail.com>
-rw-r--r-- | common/autoboot.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/common/autoboot.c b/common/autoboot.c index 9b9fb53..94133ea 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -13,6 +13,7 @@ #include <menu.h> #include <post.h> #include <u-boot/sha256.h> +#include <bootcount.h> DECLARE_GLOBAL_DATA_PTR; @@ -290,18 +291,8 @@ const char *bootdelay_process(void) { char *s; int bootdelay; -#ifdef CONFIG_BOOTCOUNT_LIMIT - unsigned long bootcount = 0; - unsigned long bootlimit = 0; -#endif /* CONFIG_BOOTCOUNT_LIMIT */ - -#ifdef CONFIG_BOOTCOUNT_LIMIT - bootcount = bootcount_load(); - bootcount++; - bootcount_store(bootcount); - env_set_ulong("bootcount", bootcount); - bootlimit = env_get_ulong("bootlimit", 10, 0); -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + + bootcount_inc(); s = env_get("bootdelay"); bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY; @@ -323,13 +314,9 @@ const char *bootdelay_process(void) s = env_get("failbootcmd"); } else #endif /* CONFIG_POST */ -#ifdef CONFIG_BOOTCOUNT_LIMIT - if (bootlimit && (bootcount > bootlimit)) { - printf("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n", - (unsigned)bootlimit); + if (bootcount_error()) s = env_get("altbootcmd"); - } else -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + else s = env_get("bootcmd"); process_fdt_options(gd->fdt_blob); |