aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/watchdog/advantechwdt.c
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2007-01-11 16:27:51 -0500
committerWim Van Sebroeck <wim@iguana.be>2007-01-11 16:27:51 -0500
commit0349a363e23a0533e081ca320c837bc08247343e (patch)
tree462d890f8e80b65f4b3ebf5cff8da0f8384aeb7d /drivers/char/watchdog/advantechwdt.c
parent1d747be647c2239e39a9b5faa138c1e36222b37e (diff)
[WATCHDOG] advantechwdt.c - move set_heartbeat to a seperate function
Put the set_heartbeat/timeout code into a seperate function Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/char/watchdog/advantechwdt.c')
-rw-r--r--drivers/char/watchdog/advantechwdt.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c
index 6c919797591a..216af0d67fd2 100644
--- a/drivers/char/watchdog/advantechwdt.c
+++ b/drivers/char/watchdog/advantechwdt.c
@@ -95,6 +95,16 @@ advwdt_disable(void)
95 inb_p(wdt_stop); 95 inb_p(wdt_stop);
96} 96}
97 97
98static int
99advwdt_set_heartbeat(int t)
100{
101 if ((t < 1) || (t > 63))
102 return -EINVAL;
103
104 timeout = t;
105 return 0;
106}
107
98/* 108/*
99 * /dev/watchdog handling 109 * /dev/watchdog handling
100 */ 110 */
@@ -151,9 +161,8 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
151 case WDIOC_SETTIMEOUT: 161 case WDIOC_SETTIMEOUT:
152 if (get_user(new_timeout, p)) 162 if (get_user(new_timeout, p))
153 return -EFAULT; 163 return -EFAULT;
154 if ((new_timeout < 1) || (new_timeout > 63)) 164 if (advwdt_set_heartbeat(new_timeout))
155 return -EINVAL; 165 return -EINVAL;
156 timeout = new_timeout;
157 advwdt_ping(); 166 advwdt_ping();
158 /* Fall */ 167 /* Fall */
159 168
@@ -267,12 +276,6 @@ advwdt_init(void)
267 276
268 printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n"); 277 printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n");
269 278
270 if (timeout < 1 || timeout > 63) {
271 timeout = WATCHDOG_TIMEOUT;
272 printk (KERN_INFO PFX "timeout value must be 1<=x<=63, using %d\n",
273 timeout);
274 }
275
276 if (wdt_stop != wdt_start) { 279 if (wdt_stop != wdt_start) {
277 if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { 280 if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
278 printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", 281 printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
@@ -289,6 +292,13 @@ advwdt_init(void)
289 goto unreg_stop; 292 goto unreg_stop;
290 } 293 }
291 294
295 /* Check that the heartbeat value is within it's range ; if not reset to the default */
296 if (advwdt_set_heartbeat(timeout)) {
297 advwdt_set_heartbeat(WATCHDOG_TIMEOUT);
298 printk (KERN_INFO PFX "timeout value must be 1<=x<=63, using %d\n",
299 timeout);
300 }
301
292 ret = register_reboot_notifier(&advwdt_notifier); 302 ret = register_reboot_notifier(&advwdt_notifier);
293 if (ret != 0) { 303 if (ret != 0) {
294 printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", 304 printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",