aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2018-05-28 02:45:45 -0400
committerWim Van Sebroeck <wim@linux-watchdog.org>2018-06-06 04:45:32 -0400
commit44ee54aabfdb3b35866ed909bde3ab01e9679385 (patch)
treecac7808dcca769272769e546da76bdaed678c6b9
parente46bb55dbc94b06f5ee466e2f50723b56781e661 (diff)
watchdog: da9063: Fix updating timeout value
The DA9063 watchdog has only one register field to store the timeout value and to enable the watchdog. The watchdog gets enabled if the value is not zero. There is no issue if the watchdog is already running but it leads into problems if the watchdog is disabled. If the watchdog is disabled and only the timeout value should be prepared the watchdog gets enabled too. Add a check to get the current watchdog state and update the watchdog timeout value on hw-side only if the watchdog is already active. Fixes: 5e9c16e37608 ("watchdog: Add DA9063 PMIC watchdog driver.") Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
-rw-r--r--drivers/watchdog/da9063_wdt.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index c1216e61e64e..6b0092b7d5a6 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -121,10 +121,23 @@ static int da9063_wdt_set_timeout(struct watchdog_device *wdd,
121{ 121{
122 struct da9063 *da9063 = watchdog_get_drvdata(wdd); 122 struct da9063 *da9063 = watchdog_get_drvdata(wdd);
123 unsigned int selector; 123 unsigned int selector;
124 int ret; 124 int ret = 0;
125 125
126 selector = da9063_wdt_timeout_to_sel(timeout); 126 selector = da9063_wdt_timeout_to_sel(timeout);
127 ret = _da9063_wdt_set_timeout(da9063, selector); 127
128 /*
129 * There are two cases when a set_timeout() will be called:
130 * 1. The watchdog is off and someone wants to set the timeout for the
131 * further use.
132 * 2. The watchdog is already running and a new timeout value should be
133 * set.
134 *
135 * The watchdog can't store a timeout value not equal zero without
136 * enabling the watchdog, so the timeout must be buffered by the driver.
137 */
138 if (watchdog_active(wdd))
139 ret = _da9063_wdt_set_timeout(da9063, selector);
140
128 if (ret) 141 if (ret)
129 dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n", 142 dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n",
130 ret); 143 ret);