diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2007-01-27 15:50:53 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2007-01-27 15:50:53 -0500 |
commit | 35d55c943117864b9dff0253eb64672f048ac0f8 (patch) | |
tree | 4c6cbc4a0b813bc34bfaa566a23828224b5d7227 | |
parent | bffda5c87cf60d27a27f2e862c82c474f8e89767 (diff) |
[WATCHDOG] ib700_wdt.c stop + set_heartbeat operations
move the code to stop the watchdog and the code to
set the heartbeat of the watchdog to seperate functions.
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r-- | drivers/char/watchdog/ib700wdt.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c index 0c3c3a3e719d..5510db21090a 100644 --- a/drivers/char/watchdog/ib700wdt.c +++ b/drivers/char/watchdog/ib700wdt.c | |||
@@ -122,7 +122,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" _ | |||
122 | 122 | ||
123 | 123 | ||
124 | /* | 124 | /* |
125 | * Kernel methods. | 125 | * Watchdog Operations |
126 | */ | 126 | */ |
127 | 127 | ||
128 | static void | 128 | static void |
@@ -132,6 +132,31 @@ ibwdt_ping(void) | |||
132 | outb_p(wd_margin, WDT_START); | 132 | outb_p(wd_margin, WDT_START); |
133 | } | 133 | } |
134 | 134 | ||
135 | static void | ||
136 | ibwdt_disable(void) | ||
137 | { | ||
138 | outb_p(0, WDT_STOP); | ||
139 | } | ||
140 | |||
141 | static int | ||
142 | ibwdt_set_heartbeat(int t) | ||
143 | { | ||
144 | int i; | ||
145 | |||
146 | if ((t < 0) || (t > 30)) | ||
147 | return -EINVAL; | ||
148 | |||
149 | for (i = 0x0F; i > -1; i--) | ||
150 | if (wd_times[i] > t) | ||
151 | break; | ||
152 | wd_margin = i; | ||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | /* | ||
157 | * /dev/watchdog handling | ||
158 | */ | ||
159 | |||
135 | static ssize_t | 160 | static ssize_t |
136 | ibwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 161 | ibwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) |
137 | { | 162 | { |
@@ -159,7 +184,7 @@ static int | |||
159 | ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 184 | ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, |
160 | unsigned long arg) | 185 | unsigned long arg) |
161 | { | 186 | { |
162 | int i, new_margin; | 187 | int new_margin; |
163 | void __user *argp = (void __user *)arg; | 188 | void __user *argp = (void __user *)arg; |
164 | int __user *p = argp; | 189 | int __user *p = argp; |
165 | 190 | ||
@@ -185,12 +210,8 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
185 | case WDIOC_SETTIMEOUT: | 210 | case WDIOC_SETTIMEOUT: |
186 | if (get_user(new_margin, p)) | 211 | if (get_user(new_margin, p)) |
187 | return -EFAULT; | 212 | return -EFAULT; |
188 | if ((new_margin < 0) || (new_margin > 30)) | 213 | if (ibwdt_set_heartbeat(new_margin)) |
189 | return -EINVAL; | 214 | return -EINVAL; |
190 | for (i = 0x0F; i > -1; i--) | ||
191 | if (wd_times[i] > new_margin) | ||
192 | break; | ||
193 | wd_margin = i; | ||
194 | ibwdt_ping(); | 215 | ibwdt_ping(); |
195 | /* Fall */ | 216 | /* Fall */ |
196 | 217 | ||
@@ -226,7 +247,7 @@ ibwdt_close(struct inode *inode, struct file *file) | |||
226 | { | 247 | { |
227 | spin_lock(&ibwdt_lock); | 248 | spin_lock(&ibwdt_lock); |
228 | if (expect_close == 42) | 249 | if (expect_close == 42) |
229 | outb_p(0, WDT_STOP); | 250 | ibwdt_disable(); |
230 | else | 251 | else |
231 | printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); | 252 | printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); |
232 | 253 | ||
@@ -246,7 +267,7 @@ ibwdt_notify_sys(struct notifier_block *this, unsigned long code, | |||
246 | { | 267 | { |
247 | if (code == SYS_DOWN || code == SYS_HALT) { | 268 | if (code == SYS_DOWN || code == SYS_HALT) { |
248 | /* Turn the WDT off */ | 269 | /* Turn the WDT off */ |
249 | outb_p(0, WDT_STOP); | 270 | ibwdt_disable(); |
250 | } | 271 | } |
251 | return NOTIFY_DONE; | 272 | return NOTIFY_DONE; |
252 | } | 273 | } |