[S390] vmwatchdog: remove lock_kernel() from open() function

The lock_kernel() calls in the open() function are unnecessary because
misc_register() is called last in module_init() and concurrent open()
calls are handled by other means.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
Gerald Schaefer 2009-12-07 12:52:19 +01:00 коммит произвёл Martin Schwidefsky
Родитель 801f97b7da
Коммит feb5c5a450
1 изменённых файлов: 19 добавлений и 10 удалений

Просмотреть файл

@ -19,7 +19,6 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#include <linux/smp_lock.h>
#include <asm/ebcdic.h> #include <asm/ebcdic.h>
#include <asm/io.h> #include <asm/io.h>
@ -49,6 +48,8 @@ static unsigned int vmwdt_interval = 60;
static unsigned long vmwdt_is_open; static unsigned long vmwdt_is_open;
static int vmwdt_expect_close; static int vmwdt_expect_close;
static DEFINE_MUTEX(vmwdt_mutex);
#define VMWDT_OPEN 0 /* devnode is open or suspend in progress */ #define VMWDT_OPEN 0 /* devnode is open or suspend in progress */
#define VMWDT_RUNNING 1 /* The watchdog is armed */ #define VMWDT_RUNNING 1 /* The watchdog is armed */
@ -133,15 +134,11 @@ static int __init vmwdt_probe(void)
static int vmwdt_open(struct inode *i, struct file *f) static int vmwdt_open(struct inode *i, struct file *f)
{ {
int ret; int ret;
lock_kernel(); if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open))
if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) {
unlock_kernel();
return -EBUSY; return -EBUSY;
}
ret = vmwdt_keepalive(); ret = vmwdt_keepalive();
if (ret) if (ret)
clear_bit(VMWDT_OPEN, &vmwdt_is_open); clear_bit(VMWDT_OPEN, &vmwdt_is_open);
unlock_kernel();
return ret ? ret : nonseekable_open(i, f); return ret ? ret : nonseekable_open(i, f);
} }
@ -160,8 +157,7 @@ static struct watchdog_info vmwdt_info = {
.identity = "z/VM Watchdog Timer", .identity = "z/VM Watchdog Timer",
}; };
static int vmwdt_ioctl(struct inode *i, struct file *f, static int __vmwdt_ioctl(unsigned int cmd, unsigned long arg)
unsigned int cmd, unsigned long arg)
{ {
switch (cmd) { switch (cmd) {
case WDIOC_GETSUPPORT: case WDIOC_GETSUPPORT:
@ -205,10 +201,19 @@ static int vmwdt_ioctl(struct inode *i, struct file *f,
case WDIOC_KEEPALIVE: case WDIOC_KEEPALIVE:
return vmwdt_keepalive(); return vmwdt_keepalive();
} }
return -EINVAL; return -EINVAL;
} }
static long vmwdt_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
{
int rc;
mutex_lock(&vmwdt_mutex);
rc = __vmwdt_ioctl(cmd, arg);
mutex_unlock(&vmwdt_mutex);
return (long) rc;
}
static ssize_t vmwdt_write(struct file *f, const char __user *buf, static ssize_t vmwdt_write(struct file *f, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
@ -288,7 +293,7 @@ static struct notifier_block vmwdt_power_notifier = {
static const struct file_operations vmwdt_fops = { static const struct file_operations vmwdt_fops = {
.open = &vmwdt_open, .open = &vmwdt_open,
.release = &vmwdt_close, .release = &vmwdt_close,
.ioctl = &vmwdt_ioctl, .unlocked_ioctl = &vmwdt_ioctl,
.write = &vmwdt_write, .write = &vmwdt_write,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
@ -309,6 +314,10 @@ static int __init vmwdt_init(void)
ret = register_pm_notifier(&vmwdt_power_notifier); ret = register_pm_notifier(&vmwdt_power_notifier);
if (ret) if (ret)
return ret; return ret;
/*
* misc_register() has to be the last action in module_init(), because
* file operations will be available right after this.
*/
ret = misc_register(&vmwdt_dev); ret = misc_register(&vmwdt_dev);
if (ret) { if (ret) {
unregister_pm_notifier(&vmwdt_power_notifier); unregister_pm_notifier(&vmwdt_power_notifier);