Many SoCs feature multiple instances of the same watchdog IP. For example, the i.MX8MP has three watchdogs, which would be called wdog0, wdog1, wdog2 in barebox, but they would all have imxwd as restart handler name. To be able to differentiate between them for restart purposes, add an optional device member that's used as fallback when no exact restart handler name was found. To make this visible to the user, also change reset -l to list the device name if it exists. Once we assign i.MX watchdog restart handlers a device pointer, the reset -l output would look like this: watchdog-restart 10 imxwd-warm 90 W imxwd wdog0 100 imxwd-warm 90 W imxwd wdog1 100 imxwd-warm 90 W imxwd wdog2 100 Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- common/restart.c | 11 ++++++++--- include/restart.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/restart.c b/common/restart.c index 35cfb542519d..2bdee289831c 100644 --- a/common/restart.c +++ b/common/restart.c @@ -82,8 +82,12 @@ struct restart_handler *restart_handler_get_by_name(const char *name, int flags) unsigned int priority = 0; list_for_each_entry(tmp, &restart_handler_list, list) { - if (name && tmp->name && strcmp(name, tmp->name)) - continue; + if (name) { + if ((tmp->name && strcmp(name, tmp->name)) && + (tmp->dev && strcmp(name, dev_name(tmp->dev)))) + continue; + } + if (flags && (tmp->flags & flags) != flags) continue; if (tmp->priority > priority) { @@ -120,7 +124,8 @@ void restart_handlers_print(void) struct restart_handler *tmp; list_for_each_entry(tmp, &restart_handler_list, list) { - printf("%-20s %6d ", tmp->name, tmp->priority); + printf("%-20s %-20s %6d ", + tmp->name, tmp->dev ? dev_name(tmp->dev) : "", tmp->priority); if (tmp->flags & RESTART_FLAG_WARM_BOOTROM) putchar('W'); putchar('\n'); diff --git a/include/restart.h b/include/restart.h index 15f30bb7ad4d..02db7915075e 100644 --- a/include/restart.h +++ b/include/restart.h @@ -21,6 +21,7 @@ struct restart_handler { int flags; struct device_node *of_node; const char *name; + struct device *dev; struct list_head list; }; -- 2.39.2