From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] restart: allow selecting restart handler by device name
Date: Mon, 29 Jul 2024 16:30:06 +0200 [thread overview]
Message-ID: <20240729143007.1558035-1-a.fatoum@pengutronix.de> (raw)
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@pengutronix.de>
---
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
next reply other threads:[~2024-07-29 14:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 14:30 Ahmad Fatoum [this message]
2024-07-29 14:30 ` [PATCH 2/2] watchdog: imxwd: populate device pointer when registering restart handler Ahmad Fatoum
2024-07-30 10:19 ` [PATCH 1/2] restart: allow selecting restart handler by device name Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240729143007.1558035-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox