From: Georg Hofmann Date: Mon, 8 Apr 2019 19:25:54 +0000 (+0200) Subject: watchdog: imx2_wdt: Fix set_timeout for big timeout values X-Git-Tag: v5.4-rc1~1007^2~99 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b07e228eee69601addba98b47b1a3850569e5013;p=platform%2Fkernel%2Flinux-rpi.git watchdog: imx2_wdt: Fix set_timeout for big timeout values The documentated behavior is: if max_hw_heartbeat_ms is implemented, the minimum of the set_timeout argument and max_hw_heartbeat_ms should be used. This patch implements this behavior. Previously only the first 7bits were used and the input argument was returned. Signed-off-by: Georg Hofmann Reviewed-by: Guenter Roeck Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 1b0faa2..a606005d 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -178,8 +178,10 @@ static void __imx2_wdt_set_timeout(struct watchdog_device *wdog, static int imx2_wdt_set_timeout(struct watchdog_device *wdog, unsigned int new_timeout) { - __imx2_wdt_set_timeout(wdog, new_timeout); + unsigned int actual; + actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000); + __imx2_wdt_set_timeout(wdog, actual); wdog->timeout = new_timeout; return 0; }