diff options
Diffstat (limited to 'common/bootchooser.c')
-rw-r--r-- | common/bootchooser.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/common/bootchooser.c b/common/bootchooser.c index 2f22e03c47..022e225165 100644 --- a/common/bootchooser.c +++ b/common/bootchooser.c @@ -13,7 +13,7 @@ #include <libfile.h> #include <common.h> #include <malloc.h> -#include <printk.h> +#include <linux/printk.h> #include <xfuncs.h> #include <envfs.h> #include <errno.h> @@ -77,6 +77,7 @@ struct bootchooser_target { enum reset_attempts { RESET_ATTEMPTS_POWER_ON, RESET_ATTEMPTS_ALL_ZERO, + RESET_ATTEMPTS_SRC_RST, }; static unsigned long reset_attempts; @@ -128,7 +129,7 @@ static void pr_target(struct bootchooser_target *target) printf(" disabled due to %s\n", reason); } -static int pr_setenv(struct bootchooser *bc, const char *fmt, ...) +static int bc_setenv(struct bootchooser *bc, const char *fmt, ...) { va_list ap; int ret = 0; @@ -162,7 +163,7 @@ err: return ret; } -static const char *pr_getenv(const char *fmt, ...) +static const char *bc_getenv(const char *fmt, ...) { va_list ap; char *str; @@ -258,7 +259,7 @@ static struct bootchooser_target *bootchooser_target_new(struct bootchooser *bc, target->remaining_attempts = 0; } - val = pr_getenv("%s.boot", target->prefix); + val = bc_getenv("%s.boot", target->prefix); if (!val) val = target->name; target->boot = xstrdup(val); @@ -439,6 +440,13 @@ struct bootchooser *bootchooser_get(void) attempts_resetted = 1; } + if (test_bit(RESET_ATTEMPTS_SRC_RST, &reset_attempts) && + reset_source_get() == RESET_RST && !attempts_resetted) { + pr_info("RST Reset, resetting remaining attempts\n"); + bootchooser_reset_attempts(bc); + attempts_resetted = 1; + } + if (test_bit(RESET_ATTEMPTS_ALL_ZERO, &reset_attempts)) { int attempts = 0; @@ -497,17 +505,17 @@ int bootchooser_save(struct bootchooser *bc) int ret; if (bc->last_chosen) - pr_setenv(bc, "%s.last_chosen=%d", bc->state_prefix, + bc_setenv(bc, "%s.last_chosen=%d", bc->state_prefix, bc->last_chosen->id); list_for_each_entry(target, &bc->targets, list) { - ret = pr_setenv(bc, "%s.remaining_attempts=%d", + ret = bc_setenv(bc, "%s.remaining_attempts=%d", target->state_prefix, target->remaining_attempts); if (ret) return ret; - ret = pr_setenv(bc, "%s.priority=%d", + ret = bc_setenv(bc, "%s.priority=%d", target->state_prefix, target->priority); if (ret) return ret; @@ -915,6 +923,7 @@ static int bootchooser_add_entry(struct bootentries *entries, const char *name) static const char * const reset_attempts_names[] = { [RESET_ATTEMPTS_POWER_ON] = "power-on", [RESET_ATTEMPTS_ALL_ZERO] = "all-zero", + [RESET_ATTEMPTS_SRC_RST] = "reset", }; static const char * const reset_priorities_names[] = { @@ -951,6 +960,8 @@ BAREBOX_MAGICVAR(global.bootchooser.targets, "bootchooser: Space separated list of target names"); BAREBOX_MAGICVAR(global.bootchooser.default_attempts, "bootchooser: Default number of attempts for a target"); +BAREBOX_MAGICVAR(global.bootchooser.reset_attempts, + "bootchooser: Choose condition to reset number of attempts for all enabled targets ('power-on', 'all-zero', 'reset')"); BAREBOX_MAGICVAR(global.bootchooser.default_priority, "bootchooser: Default priority for a target"); BAREBOX_MAGICVAR(global.bootchooser.state_prefix, |