aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-02-10 01:43:57 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 10:51:21 -0800
commit42d36115d25725fb551250c8f70602a12aa8dee2 (patch)
tree8adf4535d3f79c4a590100407f229e21c05a2080 /arch
parent4ea21cd9173a0ffa75dc74cc46d08dfc45654f29 (diff)
[PATCH] uml: watchdog driver locking
Replace BKL use with a spinlock. Also fix the control so that open doesn't return holding a lock. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/um/drivers/harddog_kern.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index 64ff22aa077..94bbcb5b922 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -44,12 +44,13 @@
#include <linux/reboot.h>
#include <linux/smp_lock.h>
#include <linux/init.h>
+#include <linux/spinlock.h>
#include <asm/uaccess.h>
#include "mconsole.h"
MODULE_LICENSE("GPL");
-/* Locked by the BKL in harddog_open and harddog_release */
+static DEFINE_SPINLOCK(lock);
static int timer_alive;
static int harddog_in_fd = -1;
static int harddog_out_fd = -1;
@@ -62,12 +63,12 @@ extern int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock);
static int harddog_open(struct inode *inode, struct file *file)
{
- int err;
+ int err = -EBUSY;
char *sock = NULL;
- lock_kernel();
+ spin_lock(&lock);
if(timer_alive)
- return -EBUSY;
+ goto err;
#ifdef CONFIG_HARDDOG_NOWAYOUT
__module_get(THIS_MODULE);
#endif
@@ -76,11 +77,15 @@ static int harddog_open(struct inode *inode, struct file *file)
sock = mconsole_notify_socket();
#endif
err = start_watchdog(&harddog_in_fd, &harddog_out_fd, sock);
- if(err) return(err);
+ if(err)
+ goto err;
timer_alive = 1;
- unlock_kernel();
+ spin_unlock(&lock);
return nonseekable_open(inode, file);
+err:
+ spin_unlock(&lock);
+ return err;
}
extern void stop_watchdog(int in_fd, int out_fd);
@@ -90,14 +95,16 @@ static int harddog_release(struct inode *inode, struct file *file)
/*
* Shut off the timer.
*/
- lock_kernel();
+
+ spin_lock(&lock);
stop_watchdog(harddog_in_fd, harddog_out_fd);
harddog_in_fd = -1;
harddog_out_fd = -1;
timer_alive=0;
- unlock_kernel();
+ spin_unlock(&lock);
+
return 0;
}