diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-06-02 09:57:57 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-09-15 14:42:49 +0200 |
commit | d97016d3a53e5d9959f1e2b966c7cd0922f6bba3 (patch) | |
tree | 2e975aafefbb4d8ae55a57fe616007739b94f3fa /common | |
parent | 119d453c0b40d4a477781626f944d74d439956da (diff) | |
download | barebox-d97016d3a53e5d9959f1e2b966c7cd0922f6bba3.tar.gz barebox-d97016d3a53e5d9959f1e2b966c7cd0922f6bba3.tar.xz |
commands: reset: allow specifying reset by name
So far, we were fine by using the highest priority restart handler
whenever more than one was available. There are reasons to want to
configure this however:
- When communicating with BootROM, e.g. to force boot from recovery
mode: The reset chosen must not cause the reboot mode stored to
volatile memory to vanish
- When testing (undocumented) reset behavior, e.g. to analyze how
the EFI reset behaves
Extend the reset command to support this. When no extra command line
option is supplied, the old behavior is maintained.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/restart.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/common/restart.c b/common/restart.c index 0f9e03765d..2bf7b166b0 100644 --- a/common/restart.c +++ b/common/restart.c @@ -75,20 +75,33 @@ int restart_handler_register_fn(const char *name, } /** - * restart_machine() - reset the whole system + * restart_handler_get_by_name() - reset the whole system */ -void __noreturn restart_machine(void) +struct restart_handler *restart_handler_get_by_name(const char *name) { struct restart_handler *rst = NULL, *tmp; unsigned int priority = 0; list_for_each_entry(tmp, &restart_handler_list, list) { + if (name && tmp->name && strcmp(name, tmp->name)) + continue; if (tmp->priority > priority) { priority = tmp->priority; rst = tmp; } } + return rst; +} + +/** + * restart_machine() - reset the whole system + */ +void __noreturn restart_machine(void) +{ + struct restart_handler *rst; + + rst = restart_handler_get_by_name(NULL); if (rst) { pr_debug("%s: using restart handler %s\n", __func__, rst->name); console_flush(); @@ -112,3 +125,14 @@ unsigned int of_get_restart_priority(struct device_node *node) return priority; } + +/* + * restart_handlers_print - print informations about all restart handlers + */ +void restart_handlers_print(void) +{ + struct restart_handler *tmp; + + list_for_each_entry(tmp, &restart_handler_list, list) + printf("%-20s %6d\n", tmp->name, tmp->priority); +} |