aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2007-01-27 16:12:54 -0500
committerWim Van Sebroeck <wim@iguana.be>2007-01-27 16:12:54 -0500
commite42162a46d948769c8b45d25ee81827bc7dac435 (patch)
tree2854abbb393da9a62655c8da0b485659960b7868 /drivers
parentc9d7710ea2b497784314a916a39d4d390855a557 (diff)
[WATCHDOG] ib700wdt.c spinlock/WDIOC_SETOPTIONS changes
Add the WDIOC_SETOPTIONS ioctl call. Because of this we move the spinlocking to the different watchdog operations. Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/watchdog/ib700wdt.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c
index 3cec6790893e..be61e4755891 100644
--- a/drivers/char/watchdog/ib700wdt.c
+++ b/drivers/char/watchdog/ib700wdt.c
@@ -128,14 +128,20 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" _
128static void 128static void
129ibwdt_ping(void) 129ibwdt_ping(void)
130{ 130{
131 spin_lock(&ibwdt_lock);
132
131 /* Write a watchdog value */ 133 /* Write a watchdog value */
132 outb_p(wd_margin, WDT_START); 134 outb_p(wd_margin, WDT_START);
135
136 spin_unlock(&ibwdt_lock);
133} 137}
134 138
135static void 139static void
136ibwdt_disable(void) 140ibwdt_disable(void)
137{ 141{
142 spin_lock(&ibwdt_lock);
138 outb_p(0, WDT_STOP); 143 outb_p(0, WDT_STOP);
144 spin_unlock(&ibwdt_lock);
139} 145}
140 146
141static int 147static int
@@ -218,7 +224,26 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
218 224
219 case WDIOC_GETTIMEOUT: 225 case WDIOC_GETTIMEOUT:
220 return put_user(wd_times[wd_margin], p); 226 return put_user(wd_times[wd_margin], p);
221 break; 227
228 case WDIOC_SETOPTIONS:
229 {
230 int options, retval = -EINVAL;
231
232 if (get_user(options, p))
233 return -EFAULT;
234
235 if (options & WDIOS_DISABLECARD) {
236 ibwdt_disable();
237 retval = 0;
238 }
239
240 if (options & WDIOS_ENABLECARD) {
241 ibwdt_ping();
242 retval = 0;
243 }
244
245 return retval;
246 }
222 247
223 default: 248 default:
224 return -ENOTTY; 249 return -ENOTTY;
@@ -229,9 +254,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
229static int 254static int
230ibwdt_open(struct inode *inode, struct file *file) 255ibwdt_open(struct inode *inode, struct file *file)
231{ 256{
232 spin_lock(&ibwdt_lock);
233 if (test_and_set_bit(0, &ibwdt_is_open)) { 257 if (test_and_set_bit(0, &ibwdt_is_open)) {
234 spin_unlock(&ibwdt_lock);
235 return -EBUSY; 258 return -EBUSY;
236 } 259 }
237 if (nowayout) 260 if (nowayout)
@@ -239,14 +262,12 @@ ibwdt_open(struct inode *inode, struct file *file)
239 262
240 /* Activate */ 263 /* Activate */
241 ibwdt_ping(); 264 ibwdt_ping();
242 spin_unlock(&ibwdt_lock);
243 return nonseekable_open(inode, file); 265 return nonseekable_open(inode, file);
244} 266}
245 267
246static int 268static int
247ibwdt_close(struct inode *inode, struct file *file) 269ibwdt_close(struct inode *inode, struct file *file)
248{ 270{
249 spin_lock(&ibwdt_lock);
250 if (expect_close == 42) { 271 if (expect_close == 42) {
251 ibwdt_disable(); 272 ibwdt_disable();
252 } else { 273 } else {
@@ -255,7 +276,6 @@ ibwdt_close(struct inode *inode, struct file *file)
255 } 276 }
256 clear_bit(0, &ibwdt_is_open); 277 clear_bit(0, &ibwdt_is_open);
257 expect_close = 0; 278 expect_close = 0;
258 spin_unlock(&ibwdt_lock);
259 return 0; 279 return 0;
260} 280}
261 281