mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: linux-watchdog@vger.kernel.org
Cc: Wim Van Sebroeck <wim@iguana.be>,
	linux-kernel@vger.kernel.org, Ian Abbott <abbotti@mev.co.uk>
Subject: [PATCH 3/5] watchdog: dw_wdt: only unregister restart handler if registered
Date: Fri, 26 Jun 2015 14:21:11 +0100	[thread overview]
Message-ID: <1435324873-18318-4-git-send-email-abbotti@mev.co.uk> (raw)
In-Reply-To: <1435324873-18318-1-git-send-email-abbotti@mev.co.uk>

If the platform driver "probe" function fails to register a restart
handler, it issues a warning and continues regardless.  The
corresponding "remove" function unregisters the restart handler
regardless.

Use bit 2 of `dw_wdt.state` to indicate whether the restart handler was
registered successfully in the "probe" function, and only unregister it
in the "remove" function if so.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 drivers/watchdog/dw_wdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index cece633..1cd877b 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -62,6 +62,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
 /* dw_wdt.state bit numbers */
 #define DW_WDT_IN_USE		0
 #define DW_WDT_PROBED		1
+#define DW_WDT_RESTART_HANDLER	2
 
 static struct {
 	void __iomem		*regs;
@@ -366,6 +367,8 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 	ret = register_restart_handler(&dw_wdt.restart_handler);
 	if (ret)
 		pr_warn("cannot register restart handler\n");
+	else
+		set_bit(DW_WDT_RESTART_HANDLER, &dw_wdt.state);
 
 	dw_wdt_set_next_heartbeat();
 	setup_timer(&dw_wdt.timer, dw_wdt_ping, 0);
@@ -384,7 +387,8 @@ out_unmark_probed:
 
 static int dw_wdt_drv_remove(struct platform_device *pdev)
 {
-	unregister_restart_handler(&dw_wdt.restart_handler);
+	if (test_and_clear_bit(DW_WDT_RESTART_HANDLER, &dw_wdt.state))
+		unregister_restart_handler(&dw_wdt.restart_handler);
 
 	misc_deregister(&dw_wdt_miscdev);
 
-- 
2.1.4


  parent reply	other threads:[~2015-06-26 13:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 13:21 [PATCH 0/5] watchdog: dw_wdt: allow only one probe + various fixes Ian Abbott
2015-06-26 13:21 ` [PATCH 1/5] watchdog: dw_wdt: prepare for more atomic bits Ian Abbott
2015-06-26 13:21 ` [PATCH 2/5] watchdog: dw_wdt: reject additional device probes Ian Abbott
2015-06-26 13:21 ` Ian Abbott [this message]
2015-06-26 13:21 ` [PATCH 4/5] watchdog: dw_wdt: unqueue timer on device removal Ian Abbott
2015-06-26 13:21 ` [PATCH 5/5] watchdog: dw_wdt: unqueue timer synchronously on unexpected close Ian Abbott
2015-06-26 13:54 ` [PATCH 0/5] watchdog: dw_wdt: allow only one probe + various fixes 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=1435324873-18318-4-git-send-email-abbotti@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®