diff options
Diffstat (limited to 'drivers/watchdog/w83697hf_wdt.c')
-rw-r--r-- | drivers/watchdog/w83697hf_wdt.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/drivers/watchdog/w83697hf_wdt.c b/drivers/watchdog/w83697hf_wdt.c index c622a0e6c9ae..528b882420b6 100644 --- a/drivers/watchdog/w83697hf_wdt.c +++ b/drivers/watchdog/w83697hf_wdt.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #define WATCHDOG_NAME "w83697hf/hg WDT" | 44 | #define WATCHDOG_NAME "w83697hf/hg WDT" |
45 | #define PFX WATCHDOG_NAME ": " | 45 | #define PFX WATCHDOG_NAME ": " |
46 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ | 46 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ |
47 | #define WATCHDOG_EARLY_DISABLE 1 /* Disable until userland kicks in */ | ||
47 | 48 | ||
48 | static unsigned long wdt_is_open; | 49 | static unsigned long wdt_is_open; |
49 | static char expect_close; | 50 | static char expect_close; |
@@ -56,12 +57,16 @@ MODULE_PARM_DESC(wdt_io, "w83697hf/hg WDT io port (default 0x2e, 0 = autodetect) | |||
56 | 57 | ||
57 | static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ | 58 | static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ |
58 | module_param(timeout, int, 0); | 59 | module_param(timeout, int, 0); |
59 | MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) "."); | 60 | MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255 (default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); |
60 | 61 | ||
61 | static int nowayout = WATCHDOG_NOWAYOUT; | 62 | static int nowayout = WATCHDOG_NOWAYOUT; |
62 | module_param(nowayout, int, 0); | 63 | module_param(nowayout, int, 0); |
63 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 64 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
64 | 65 | ||
66 | static int early_disable = WATCHDOG_EARLY_DISABLE; | ||
67 | module_param(early_disable, int, 0); | ||
68 | MODULE_PARM_DESC(early_disable, "Watchdog gets disabled at boot time (default=" __MODULE_STRING(WATCHDOG_EARLY_DISABLE) ")"); | ||
69 | |||
65 | /* | 70 | /* |
66 | * Kernel methods. | 71 | * Kernel methods. |
67 | */ | 72 | */ |
@@ -140,7 +145,7 @@ w83697hf_init(void) | |||
140 | w83697hf_deselect_wdt(); | 145 | w83697hf_deselect_wdt(); |
141 | } | 146 | } |
142 | 147 | ||
143 | static int | 148 | static void |
144 | wdt_ping(void) | 149 | wdt_ping(void) |
145 | { | 150 | { |
146 | spin_lock(&io_lock); | 151 | spin_lock(&io_lock); |
@@ -150,10 +155,9 @@ wdt_ping(void) | |||
150 | 155 | ||
151 | w83697hf_deselect_wdt(); | 156 | w83697hf_deselect_wdt(); |
152 | spin_unlock(&io_lock); | 157 | spin_unlock(&io_lock); |
153 | return 0; | ||
154 | } | 158 | } |
155 | 159 | ||
156 | static int | 160 | static void |
157 | wdt_enable(void) | 161 | wdt_enable(void) |
158 | { | 162 | { |
159 | spin_lock(&io_lock); | 163 | spin_lock(&io_lock); |
@@ -164,10 +168,9 @@ wdt_enable(void) | |||
164 | 168 | ||
165 | w83697hf_deselect_wdt(); | 169 | w83697hf_deselect_wdt(); |
166 | spin_unlock(&io_lock); | 170 | spin_unlock(&io_lock); |
167 | return 0; | ||
168 | } | 171 | } |
169 | 172 | ||
170 | static int | 173 | static void |
171 | wdt_disable(void) | 174 | wdt_disable(void) |
172 | { | 175 | { |
173 | spin_lock(&io_lock); | 176 | spin_lock(&io_lock); |
@@ -178,7 +181,22 @@ wdt_disable(void) | |||
178 | 181 | ||
179 | w83697hf_deselect_wdt(); | 182 | w83697hf_deselect_wdt(); |
180 | spin_unlock(&io_lock); | 183 | spin_unlock(&io_lock); |
181 | return 0; | 184 | } |
185 | |||
186 | static unsigned char | ||
187 | wdt_running(void) | ||
188 | { | ||
189 | unsigned char t; | ||
190 | |||
191 | spin_lock(&io_lock); | ||
192 | w83697hf_select_wdt(); | ||
193 | |||
194 | t = w83697hf_get_reg(0xF4); /* Read timer */ | ||
195 | |||
196 | w83697hf_deselect_wdt(); | ||
197 | spin_unlock(&io_lock); | ||
198 | |||
199 | return t; | ||
182 | } | 200 | } |
183 | 201 | ||
184 | static int | 202 | static int |
@@ -397,7 +415,11 @@ wdt_init(void) | |||
397 | } | 415 | } |
398 | 416 | ||
399 | w83697hf_init(); | 417 | w83697hf_init(); |
400 | wdt_disable(); /* Disable watchdog until first use */ | 418 | if (early_disable) { |
419 | if (wdt_running()) | ||
420 | printk (KERN_WARNING PFX "Stopping previously enabled watchdog until userland kicks in\n"); | ||
421 | wdt_disable(); | ||
422 | } | ||
401 | 423 | ||
402 | if (wdt_set_heartbeat(timeout)) { | 424 | if (wdt_set_heartbeat(timeout)) { |
403 | wdt_set_heartbeat(WATCHDOG_TIMEOUT); | 425 | wdt_set_heartbeat(WATCHDOG_TIMEOUT); |