watchdog: sp5100-tco: Abort if watchdog is disabled by hardware

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/f7781b067522aa269213e8025c80cbed1868d349
Commit:     f7781b067522aa269213e8025c80cbed1868d349
Parent:     17b20833ff427e285e36e4ce6e5dc8b0046fa0a4
Refname:    refs/heads/master
Author:     Guenter Roeck <[email protected]>
AuthorDate: Sun Dec 24 13:04:16 2017 -0800
Committer:  Wim Van Sebroeck <[email protected]>
CommitDate: Sun Jan 21 12:56:37 2018 +0100

    watchdog: sp5100-tco: Abort if watchdog is disabled by hardware
    
    If the watchdog control register indicates that the watchdog hardware
    is disabled even after we tried to enable it, there is no point to
    instantiate the driver.
    
    Cc: Zoltán Böszörményi <[email protected]>
    Signed-off-by: Guenter Roeck <[email protected]>
    Signed-off-by: Wim Van Sebroeck <[email protected]>
---
 drivers/watchdog/sp5100_tco.c | 8 +++++++-
 drivers/watchdog/sp5100_tco.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c
index bb6c4608c1c0..23246cb40598 100644
--- a/drivers/watchdog/sp5100_tco.c
+++ b/drivers/watchdog/sp5100_tco.c
@@ -273,14 +273,20 @@ static int sp5100_tco_setupdevice(struct device *dev,
 	/* Setup the watchdog timer */
 	tco_timer_enable();
 
-	/* Check that the watchdog action is set to reset the system */
 	val = readl(SP5100_WDT_CONTROL(tco->tcobase));
+	if (val & SP5100_WDT_DISABLED) {
+		dev_err(dev, "Watchdog hardware is disabled\n");
+		ret = -ENODEV;
+		goto unreg_region;
+	}
+
 	/*
 	 * Save WatchDogFired status, because WatchDogFired flag is
 	 * cleared here.
 	 */
 	if (val & SP5100_WDT_FIRED)
 		wdd->bootstatus = WDIOF_CARDRESET;
+	/* Set watchdog action to reset the system */
 	val &= ~SP5100_WDT_ACTION_RESET;
 	writel(val, SP5100_WDT_CONTROL(tco->tcobase));
 
diff --git a/drivers/watchdog/sp5100_tco.h b/drivers/watchdog/sp5100_tco.h
index ca0721c8d879..008b2094bd13 100644
--- a/drivers/watchdog/sp5100_tco.h
+++ b/drivers/watchdog/sp5100_tco.h
@@ -19,6 +19,7 @@
 #define SP5100_WDT_START_STOP_BIT	BIT(0)
 #define SP5100_WDT_FIRED		BIT(1)
 #define SP5100_WDT_ACTION_RESET		BIT(2)
+#define SP5100_WDT_DISABLED		BIT(3)
 #define SP5100_WDT_TRIGGER_BIT		BIT(7)
 
 #define SP5100_PM_IOPORTS_SIZE		0x02
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.