aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-05-19 09:08:22 -0400
committerWim Van Sebroeck <wim@iguana.be>2008-06-21 10:42:05 -0400
commit9f53c8de1aef08cad678dcda0f85fd8914ad7666 (patch)
treed9a9c428606a7fc9a87ad03ff78a33b0f304da6a /drivers/watchdog
parent619a8a2bb1d0c3f8270da4496a30f1e83e6eab5e (diff)
[WATCHDOG 39/57] sbc8360: clean up
Review and switch to unlocked_ioctl Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/sbc8360.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/drivers/watchdog/sbc8360.c b/drivers/watchdog/sbc8360.c
index 2ee2677f3648..c66fa6694fc3 100644
--- a/drivers/watchdog/sbc8360.c
+++ b/drivers/watchdog/sbc8360.c
@@ -48,13 +48,12 @@
48#include <linux/init.h> 48#include <linux/init.h>
49#include <linux/spinlock.h> 49#include <linux/spinlock.h>
50#include <linux/moduleparam.h> 50#include <linux/moduleparam.h>
51#include <linux/io.h>
52#include <linux/uaccess.h>
51 53
52#include <asm/io.h>
53#include <asm/uaccess.h>
54#include <asm/system.h> 54#include <asm/system.h>
55 55
56static unsigned long sbc8360_is_open; 56static unsigned long sbc8360_is_open;
57static DEFINE_SPINLOCK(sbc8360_lock);
58static char expect_close; 57static char expect_close;
59 58
60#define PFX "sbc8360: " 59#define PFX "sbc8360: "
@@ -204,7 +203,8 @@ module_param(timeout, int, 0);
204MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))"); 203MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))");
205module_param(nowayout, int, 0); 204module_param(nowayout, int, 0);
206MODULE_PARM_DESC(nowayout, 205MODULE_PARM_DESC(nowayout,
207 "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 206 "Watchdog cannot be stopped once started (default="
207 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
208 208
209/* 209/*
210 * Kernel methods. 210 * Kernel methods.
@@ -232,8 +232,8 @@ static void sbc8360_ping(void)
232} 232}
233 233
234/* Userspace pings kernel driver, or requests clean close */ 234/* Userspace pings kernel driver, or requests clean close */
235static ssize_t sbc8360_write(struct file *file, const char __user * buf, 235static ssize_t sbc8360_write(struct file *file, const char __user *buf,
236 size_t count, loff_t * ppos) 236 size_t count, loff_t *ppos)
237{ 237{
238 if (count) { 238 if (count) {
239 if (!nowayout) { 239 if (!nowayout) {
@@ -257,16 +257,12 @@ static ssize_t sbc8360_write(struct file *file, const char __user * buf,
257 257
258static int sbc8360_open(struct inode *inode, struct file *file) 258static int sbc8360_open(struct inode *inode, struct file *file)
259{ 259{
260 spin_lock(&sbc8360_lock); 260 if (test_and_set_bit(0, &sbc8360_is_open))
261 if (test_and_set_bit(0, &sbc8360_is_open)) {
262 spin_unlock(&sbc8360_lock);
263 return -EBUSY; 261 return -EBUSY;
264 }
265 if (nowayout) 262 if (nowayout)
266 __module_get(THIS_MODULE); 263 __module_get(THIS_MODULE);
267 264
268 /* Activate and ping once to start the countdown */ 265 /* Activate and ping once to start the countdown */
269 spin_unlock(&sbc8360_lock);
270 sbc8360_activate(); 266 sbc8360_activate();
271 sbc8360_ping(); 267 sbc8360_ping();
272 return nonseekable_open(inode, file); 268 return nonseekable_open(inode, file);
@@ -274,16 +270,14 @@ static int sbc8360_open(struct inode *inode, struct file *file)
274 270
275static int sbc8360_close(struct inode *inode, struct file *file) 271static int sbc8360_close(struct inode *inode, struct file *file)
276{ 272{
277 spin_lock(&sbc8360_lock);
278 if (expect_close == 42) 273 if (expect_close == 42)
279 outb(0, SBC8360_ENABLE); 274 outb(0, SBC8360_ENABLE);
280 else 275 else
281 printk(KERN_CRIT PFX 276 printk(KERN_CRIT PFX
282 "SBC8360 device closed unexpectedly. SBC8360 will not stop!\n"); 277 "SBC8360 device closed unexpectedly. SBC8360 will not stop!\n");
283 278
284 clear_bit(0, &sbc8360_is_open); 279 clear_bit(0, &sbc8360_is_open);
285 expect_close = 0; 280 expect_close = 0;
286 spin_unlock(&sbc8360_lock);
287 return 0; 281 return 0;
288} 282}
289 283
@@ -382,13 +376,13 @@ static int __init sbc8360_init(void)
382 376
383 return 0; 377 return 0;
384 378
385 out_nomisc: 379out_nomisc:
386 unregister_reboot_notifier(&sbc8360_notifier); 380 unregister_reboot_notifier(&sbc8360_notifier);
387 out_noreboot: 381out_noreboot:
388 release_region(SBC8360_BASETIME, 1); 382 release_region(SBC8360_BASETIME, 1);
389 out_nobasetimereg: 383out_nobasetimereg:
390 release_region(SBC8360_ENABLE, 1); 384 release_region(SBC8360_ENABLE, 1);
391 out: 385out:
392 return res; 386 return res;
393} 387}
394 388