Skip to content

Commit

Permalink
watchdog: Always evaluate new timeout against min_timeout
Browse files Browse the repository at this point in the history
Up to now, a new timeout value is only evaluated against min_timeout
if max_timeout is provided. This does not really make sense; a driver
can have a minimum timeout even if it does not have a maximum timeout.
Ensure that it is not smaller than min_timeout, even if max_timeout
is not set.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Guenter Roeck authored and Wim Van Sebroeck committed Nov 3, 2015
1 parent 8cbb97e commit 1e93594
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions include/linux/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,15 @@ static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool noway
/* Use the following function to check if a timeout value is invalid */
static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigned int t)
{
return ((wdd->max_timeout != 0) &&
(t < wdd->min_timeout || t > wdd->max_timeout));
/*
* The timeout is invalid if
* - the requested value is smaller than the configured minimum timeout,
* or
* - a maximum timeout is configured, and the requested value is larger
* than the maximum timeout.
*/
return t < wdd->min_timeout ||
(wdd->max_timeout && t > wdd->max_timeout);
}

/* Use the following functions to manipulate watchdog driver specific data */
Expand Down

0 comments on commit 1e93594

Please sign in to comment.