]>
Commit | Line | Data |
---|---|---|
a65d4bac GKH |
1 | From foo@baz Sat Jul 28 10:25:26 CEST 2018 |
2 | From: Marco Felsch <m.felsch@pengutronix.de> | |
3 | Date: Mon, 28 May 2018 08:45:45 +0200 | |
4 | Subject: watchdog: da9063: Fix updating timeout value | |
5 | ||
6 | From: Marco Felsch <m.felsch@pengutronix.de> | |
7 | ||
8 | [ Upstream commit 44ee54aabfdb3b35866ed909bde3ab01e9679385 ] | |
9 | ||
10 | The DA9063 watchdog has only one register field to store the timeout value | |
11 | and to enable the watchdog. The watchdog gets enabled if the value is | |
12 | not zero. There is no issue if the watchdog is already running but it | |
13 | leads into problems if the watchdog is disabled. | |
14 | ||
15 | If the watchdog is disabled and only the timeout value should be prepared | |
16 | the watchdog gets enabled too. Add a check to get the current watchdog | |
17 | state and update the watchdog timeout value on hw-side only if the | |
18 | watchdog is already active. | |
19 | ||
20 | Fixes: 5e9c16e37608 ("watchdog: Add DA9063 PMIC watchdog driver.") | |
21 | Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> | |
22 | Reviewed-by: Guenter Roeck <linux@roeck-us.net> | |
23 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | |
24 | Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org> | |
25 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
26 | Signed-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); |