linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: only run driver set_pretimeout op if device supports it
@ 2021-06-26 23:47 Curtis Klein
  2021-06-27 15:01 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Curtis Klein @ 2021-06-26 23:47 UTC (permalink / raw)
  To: wim, linux; +Cc: linux-watchdog, linux-kernel, Curtis Klein

Some watchdog devices might conditionally support pretimeouts (e.g. if
an interrupt is exposed for the device) but some watchdog drivers might
still define the set_pretimeout operation (e.g. the mtk_wdt driver) and
indicate support at runtime through the WDIOF_PRETIMEOUT flag. If the
kernel is compiled with CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT enabled,
watchdog_set_pretimeout would run the driver specific set_pretimeout
even if WDIOF_PRETIMEOUT is not set which might have unintended
consequences.

So this change checks that the device flags and only runs the driver
operation if pretimeouts are supported.

Signed-off-by: Curtis Klein <curtis.klein@hpe.com>
---
 drivers/watchdog/watchdog_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 3bab324..5bf795c 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -401,7 +401,7 @@ static int watchdog_set_pretimeout(struct watchdog_device *wdd,
 	if (watchdog_pretimeout_invalid(wdd, timeout))
 		return -EINVAL;
 
-	if (wdd->ops->set_pretimeout)
+	if (wdd->ops->set_pretimeout && (wdd->info->options & WDIOF_PRETIMEOUT))
 		err = wdd->ops->set_pretimeout(wdd, timeout);
 	else
 		wdd->pretimeout = timeout;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-27 15:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-26 23:47 [PATCH] watchdog: only run driver set_pretimeout op if device supports it Curtis Klein
2021-06-27 15:01 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).