]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/watchdog-imx2_wdt-fix-set_timeout-for-big-timeout-va.patch
d557ac47d25f79646746c56e60087111ff2695ce
[thirdparty/kernel/stable-queue.git] / queue-4.19 / watchdog-imx2_wdt-fix-set_timeout-for-big-timeout-va.patch
1 From 5857edd5636dcad8394f9baf8fdbf3d07affdcff Mon Sep 17 00:00:00 2001
2 From: Georg Hofmann <georg@hofmannsweb.com>
3 Date: Mon, 8 Apr 2019 21:25:54 +0200
4 Subject: watchdog: imx2_wdt: Fix set_timeout for big timeout values
5
6 [ Upstream commit b07e228eee69601addba98b47b1a3850569e5013 ]
7
8 The documentated behavior is: if max_hw_heartbeat_ms is implemented, the
9 minimum of the set_timeout argument and max_hw_heartbeat_ms should be used.
10 This patch implements this behavior.
11 Previously only the first 7bits were used and the input argument was
12 returned.
13
14 Signed-off-by: Georg Hofmann <georg@hofmannsweb.com>
15 Reviewed-by: Guenter Roeck <linux@roeck-us.net>
16 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
17 Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
18 Signed-off-by: Sasha Levin <sashal@kernel.org>
19 ---
20 drivers/watchdog/imx2_wdt.c | 4 +++-
21 1 file changed, 3 insertions(+), 1 deletion(-)
22
23 diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
24 index 2b52514eaa86..7e7bdcbbc741 100644
25 --- a/drivers/watchdog/imx2_wdt.c
26 +++ b/drivers/watchdog/imx2_wdt.c
27 @@ -178,8 +178,10 @@ static void __imx2_wdt_set_timeout(struct watchdog_device *wdog,
28 static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
29 unsigned int new_timeout)
30 {
31 - __imx2_wdt_set_timeout(wdog, new_timeout);
32 + unsigned int actual;
33
34 + actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000);
35 + __imx2_wdt_set_timeout(wdog, actual);
36 wdog->timeout = new_timeout;
37 return 0;
38 }
39 --
40 2.20.1
41