@@ -46,15 +46,16 @@ static unsigned int da9063_wdt_timeout_to_sel(unsigned int secs)
46
46
}
47
47
48
48
/*
49
- * Return 0 if watchdog is disabled, else non zero.
49
+ * Read the currently active timeout.
50
+ * Zero means the watchdog is disabled.
50
51
*/
51
- static unsigned int da9063_wdt_is_running (struct da9063 * da9063 )
52
+ static unsigned int da9063_wdt_read_timeout (struct da9063 * da9063 )
52
53
{
53
54
unsigned int val ;
54
55
55
56
regmap_read (da9063 -> regmap , DA9063_REG_CONTROL_D , & val );
56
57
57
- return val & DA9063_TWDSCALE_MASK ;
58
+ return wdt_timeout [ val & DA9063_TWDSCALE_MASK ] ;
58
59
}
59
60
60
61
static int da9063_wdt_disable_timer (struct da9063 * da9063 )
@@ -191,6 +192,7 @@ static int da9063_wdt_probe(struct platform_device *pdev)
191
192
struct device * dev = & pdev -> dev ;
192
193
struct da9063 * da9063 ;
193
194
struct watchdog_device * wdd ;
195
+ unsigned int timeout ;
194
196
195
197
if (!dev -> parent )
196
198
return - EINVAL ;
@@ -214,13 +216,19 @@ static int da9063_wdt_probe(struct platform_device *pdev)
214
216
watchdog_set_restart_priority (wdd , 128 );
215
217
watchdog_set_drvdata (wdd , da9063 );
216
218
217
- /* Set default timeout, maybe override it with DT value, scale it */
218
219
wdd -> timeout = DA9063_WDG_TIMEOUT ;
220
+
221
+ /* Use pre-configured timeout if watchdog is already running. */
222
+ timeout = da9063_wdt_read_timeout (da9063 );
223
+ if (timeout )
224
+ wdd -> timeout = timeout ;
225
+
226
+ /* Set timeout, maybe override it with DT value, scale it */
219
227
watchdog_init_timeout (wdd , 0 , dev );
220
228
da9063_wdt_set_timeout (wdd , wdd -> timeout );
221
229
222
- /* Change the timeout to the default value if the watchdog is running */
223
- if (da9063_wdt_is_running ( da9063 ) ) {
230
+ /* Update timeout if the watchdog is already running. */
231
+ if (timeout ) {
224
232
da9063_wdt_update_timeout (da9063 , wdd -> timeout );
225
233
set_bit (WDOG_HW_RUNNING , & wdd -> status );
226
234
}
0 commit comments