linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] watchdog: core: Make dt "timeout-sec" property work on drivers w/out min/max
@ 2013-11-26 18:22 Doug Anderson
  2013-11-26 18:22 ` [PATCH 2/2] watchdog: core: Fix watchdog_init_timeout() when invalid param / valid dt Doug Anderson
  2013-11-26 18:58 ` [PATCH 1/2] watchdog: core: Make dt "timeout-sec" property work on drivers w/out min/max Guenter Roeck
  0 siblings, 2 replies; 6+ messages in thread
From: Doug Anderson @ 2013-11-26 18:22 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: Fabio Porcedda, Sachin Kamat, Guenter Roeck, Doug Anderson,
	linux-watchdog, linux-kernel

It is valid for a watchdog driver to have 0 for a "min" and "max"
timeout if the driver doesn't need the core to enforce the concepts of
min and max.  The s3c2410_wdt driver is one such driver.  Specifically
it can be hard for that driver to come up with a static "max" on all
platforms without a lot more information since the input clock on
S3C2410 and S3C2440 can change with DVFS.

As written, watchdog_init_timeout() will not ever read "timeout-sec"
on these drivers since watchdog_timeout_invalid() will _never_ return
true.  Change to not consider a timeout_parm of 0 as valid even if
min/max aren't specified by the driver.  Also handle the case when
there is no min/max and no "timeout-sec" property.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/watchdog/watchdog_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 461336c..cec9b55 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -78,7 +78,7 @@ int watchdog_init_timeout(struct watchdog_device *wdd,
 	watchdog_check_min_max_timeout(wdd);
 
 	/* try to get the timeout module parameter first */
-	if (!watchdog_timeout_invalid(wdd, timeout_parm)) {
+	if (!watchdog_timeout_invalid(wdd, timeout_parm) && timeout_parm) {
 		wdd->timeout = timeout_parm;
 		return ret;
 	}
@@ -89,7 +89,7 @@ int watchdog_init_timeout(struct watchdog_device *wdd,
 	if (dev == NULL || dev->of_node == NULL)
 		return ret;
 	of_property_read_u32(dev->of_node, "timeout-sec", &t);
-	if (!watchdog_timeout_invalid(wdd, t))
+	if (!watchdog_timeout_invalid(wdd, t) && t)
 		wdd->timeout = t;
 	else
 		ret = -EINVAL;
-- 
1.8.4.1


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

end of thread, other threads:[~2013-11-26 19:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 18:22 [PATCH 1/2] watchdog: core: Make dt "timeout-sec" property work on drivers w/out min/max Doug Anderson
2013-11-26 18:22 ` [PATCH 2/2] watchdog: core: Fix watchdog_init_timeout() when invalid param / valid dt Doug Anderson
2013-11-26 18:58   ` Guenter Roeck
2013-11-26 19:23     ` Doug Anderson
2013-11-26 19:51       ` Guenter Roeck
2013-11-26 18:58 ` [PATCH 1/2] watchdog: core: Make dt "timeout-sec" property work on drivers w/out min/max 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).