From: Alexander Stein <alexander.stein@systec-electronic.com>
To: Wim Van Sebroeck <wim@iguana.be>
Cc: Alexander Stein <alexander.stein@systec-electronic.com>,
linux-watchdog@vger.kernel.org
Subject: [PATCH 2/2] watchdog: gpio-wdt: Add panic notifier
Date: Mon, 9 Nov 2015 10:55:44 +0100 [thread overview]
Message-ID: <1447062944-12296-2-git-send-email-alexander.stein@systec-electronic.com> (raw)
In-Reply-To: <1447062944-12296-1-git-send-email-alexander.stein@systec-electronic.com>
This notifier is required when the watchdog is configured as always running
because in this case the watchdog will be triggered when the kernel panics
at boot before any application could open the device, e.g. because the
rootfs is broken. This should result in a resetting system. Thus we
register a panic notifier which stops triggering the watchdog.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
drivers/watchdog/gpio_wdt.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index c7b8a06..aaa0815 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -37,6 +37,7 @@ struct gpio_wdt_priv {
unsigned int hw_margin;
unsigned long last_jiffies;
struct notifier_block reboot_notifier;
+ struct notifier_block panic_notifier;
struct timer_list timer;
struct watchdog_device wdd;
};
@@ -146,6 +147,17 @@ static int gpio_wdt_notify_sys(struct notifier_block *nb, unsigned long code,
return NOTIFY_DONE;
}
+static int gpio_wdt_notify_panic(struct notifier_block *nb, unsigned long code,
+ void *unused)
+{
+ struct gpio_wdt_priv *priv = container_of(nb, struct gpio_wdt_priv,
+ panic_notifier);
+
+ gpio_wdt_disable(priv);
+
+ return NOTIFY_DONE;
+}
+
static const struct watchdog_info gpio_wdt_ident = {
.options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING |
WDIOF_SETTIMEOUT,
@@ -233,11 +245,19 @@ static int gpio_wdt_probe(struct platform_device *pdev)
if (ret)
goto error_unregister;
+ priv->panic_notifier.notifier_call = gpio_wdt_notify_panic;
+ ret = atomic_notifier_chain_register(&panic_notifier_list,
+ &priv->panic_notifier);
+ if (ret)
+ goto error_unregister_notify;
+
if (priv->always_running)
gpio_wdt_start_impl(priv);
return 0;
+error_unregister_notify:
+ unregister_reboot_notifier(&priv->reboot_notifier);
error_unregister:
watchdog_unregister_device(&priv->wdd);
return ret;
--
2.4.10
next prev parent reply other threads:[~2015-11-09 9:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 9:55 [PATCH 1/2] watchdog: gpio-wdt: Rename notifier to reboot_notifier Alexander Stein
2015-11-09 9:55 ` Alexander Stein [this message]
2015-11-09 15:19 ` [PATCH 2/2] watchdog: gpio-wdt: Add panic notifier Guenter Roeck
2015-11-09 15:46 ` Alexander Stein
2015-11-09 19:02 ` Uwe Kleine-König
2015-11-09 23:19 ` Guenter Roeck
2015-11-10 7:20 ` Uwe Kleine-König
2015-11-13 18:44 ` Guenter Roeck
2015-11-09 15:12 ` [PATCH 1/2] watchdog: gpio-wdt: Rename notifier to reboot_notifier Guenter Roeck
2015-11-23 5:33 ` Guenter Roeck
2015-11-23 13:29 ` Alexander Stein
2015-11-23 16:02 ` Guenter Roeck
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=1447062944-12296-2-git-send-email-alexander.stein@systec-electronic.com \
--to=alexander.stein@systec-electronic.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=wim@iguana.be \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.