]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.60/watchdog-da9063-fix-updating-timeout-value.patch
Remove duplicated commits
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / watchdog-da9063-fix-updating-timeout-value.patch
CommitLineData
a65d4bac
GKH
1From foo@baz Sat Jul 28 10:25:26 CEST 2018
2From: Marco Felsch <m.felsch@pengutronix.de>
3Date: Mon, 28 May 2018 08:45:45 +0200
4Subject: watchdog: da9063: Fix updating timeout value
5
6From: Marco Felsch <m.felsch@pengutronix.de>
7
8[ Upstream commit 44ee54aabfdb3b35866ed909bde3ab01e9679385 ]
9
10The DA9063 watchdog has only one register field to store the timeout value
11and to enable the watchdog. The watchdog gets enabled if the value is
12not zero. There is no issue if the watchdog is already running but it
13leads into problems if the watchdog is disabled.
14
15If the watchdog is disabled and only the timeout value should be prepared
16the watchdog gets enabled too. Add a check to get the current watchdog
17state and update the watchdog timeout value on hw-side only if the
18watchdog is already active.
19
20Fixes: 5e9c16e37608 ("watchdog: Add DA9063 PMIC watchdog driver.")
21Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
22Reviewed-by: Guenter Roeck <linux@roeck-us.net>
23Signed-off-by: Guenter Roeck <linux@roeck-us.net>
24Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
25Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
26Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27---
28 drivers/watchdog/da9063_wdt.c | 17 +++++++++++++++--
29 1 file changed, 15 insertions(+), 2 deletions(-)
30
31--- a/drivers/watchdog/da9063_wdt.c
32+++ b/drivers/watchdog/da9063_wdt.c
33@@ -102,10 +102,23 @@ static int da9063_wdt_set_timeout(struct
34 {
35 struct da9063 *da9063 = watchdog_get_drvdata(wdd);
36 unsigned int selector;
37- int ret;
38+ int ret = 0;
39
40 selector = da9063_wdt_timeout_to_sel(timeout);
41- ret = _da9063_wdt_set_timeout(da9063, selector);
42+
43+ /*
44+ * There are two cases when a set_timeout() will be called:
45+ * 1. The watchdog is off and someone wants to set the timeout for the
46+ * further use.
47+ * 2. The watchdog is already running and a new timeout value should be
48+ * set.
49+ *
50+ * The watchdog can't store a timeout value not equal zero without
51+ * enabling the watchdog, so the timeout must be buffered by the driver.
52+ */
53+ if (watchdog_active(wdd))
54+ ret = _da9063_wdt_set_timeout(da9063, selector);
55+
56 if (ret)
57 dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n",
58 ret);