aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorGerald Schaefer <gerald.schaefer@de.ibm.com>2009-12-07 06:52:19 -0500
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>2009-12-07 06:51:38 -0500
commitfeb5c5a450a5e56f3be09a18b541996c86bd94bc (patch)
tree00ffa94a0a597e092fc3845191c932f31d0dff46 /drivers/s390
parent801f97b7da9dff4aace7111bfe0d073caf5febd2 (diff)
[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>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/char/vmwatchdog.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c
index f2bc287b69e4..c974058e48d2 100644
--- a/drivers/s390/char/vmwatchdog.c
+++ b/drivers/s390/char/vmwatchdog.c
@@ -19,7 +19,6 @@
19#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
20#include <linux/suspend.h> 20#include <linux/suspend.h>
21#include <linux/watchdog.h> 21#include <linux/watchdog.h>
22#include <linux/smp_lock.h>
23 22
24#include <asm/ebcdic.h> 23#include <asm/ebcdic.h>
25#include <asm/io.h> 24#include <asm/io.h>
@@ -49,6 +48,8 @@ static unsigned int vmwdt_interval = 60;
49static unsigned long vmwdt_is_open; 48static unsigned long vmwdt_is_open;
50static int vmwdt_expect_close; 49static int vmwdt_expect_close;
51 50
51static DEFINE_MUTEX(vmwdt_mutex);
52
52#define VMWDT_OPEN 0 /* devnode is open or suspend in progress */ 53#define VMWDT_OPEN 0 /* devnode is open or suspend in progress */
53#define VMWDT_RUNNING 1 /* The watchdog is armed */ 54#define VMWDT_RUNNING 1 /* The watchdog is armed */
54 55
@@ -133,15 +134,11 @@ static int __init vmwdt_probe(void)
133static int vmwdt_open(struct inode *i, struct file *f) 134static int vmwdt_open(struct inode *i, struct file *f)
134{ 135{
135 int ret; 136 int ret;
136 lock_kernel(); 137 if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open))
137 if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) {
138 unlock_kernel();
139 return -EBUSY; 138 return -EBUSY;
140 }
141 ret = vmwdt_keepalive(); 139 ret = vmwdt_keepalive();
142 if (ret) 140 if (ret)
143 clear_bit(VMWDT_OPEN, &vmwdt_is_open); 141 clear_bit(VMWDT_OPEN, &vmwdt_is_open);
144 unlock_kernel();
145 return ret ? ret : nonseekable_open(i, f); 142 return ret ? ret : nonseekable_open(i, f);
146} 143}
147 144
@@ -160,8 +157,7 @@ static struct watchdog_info vmwdt_info = {
160 .identity = "z/VM Watchdog Timer", 157 .identity = "z/VM Watchdog Timer",
161}; 158};
162 159
163static int vmwdt_ioctl(struct inode *i, struct file *f, 160static int __vmwdt_ioctl(unsigned int cmd, unsigned long arg)
164 unsigned int cmd, unsigned long arg)
165{ 161{
166 switch (cmd) { 162 switch (cmd) {
167 case WDIOC_GETSUPPORT: 163 case WDIOC_GETSUPPORT:
@@ -205,10 +201,19 @@ static int vmwdt_ioctl(struct inode *i, struct file *f,
205 case WDIOC_KEEPALIVE: 201 case WDIOC_KEEPALIVE:
206 return vmwdt_keepalive(); 202 return vmwdt_keepalive();
207 } 203 }
208
209 return -EINVAL; 204 return -EINVAL;
210} 205}
211 206
207static long vmwdt_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
208{
209 int rc;
210
211 mutex_lock(&vmwdt_mutex);
212 rc = __vmwdt_ioctl(cmd, arg);
213 mutex_unlock(&vmwdt_mutex);
214 return (long) rc;
215}
216
212static ssize_t vmwdt_write(struct file *f, const char __user *buf, 217static ssize_t vmwdt_write(struct file *f, const char __user *buf,
213 size_t count, loff_t *ppos) 218 size_t count, loff_t *ppos)
214{ 219{
@@ -288,7 +293,7 @@ static struct notifier_block vmwdt_power_notifier = {
288static const struct file_operations vmwdt_fops = { 293static const struct file_operations vmwdt_fops = {
289 .open = &vmwdt_open, 294 .open = &vmwdt_open,
290 .release = &vmwdt_close, 295 .release = &vmwdt_close,
291 .ioctl = &vmwdt_ioctl, 296 .unlocked_ioctl = &vmwdt_ioctl,
292 .write = &vmwdt_write, 297 .write = &vmwdt_write,
293 .owner = THIS_MODULE, 298 .owner = THIS_MODULE,
294}; 299};
@@ -309,6 +314,10 @@ static int __init vmwdt_init(void)
309 ret = register_pm_notifier(&vmwdt_power_notifier); 314 ret = register_pm_notifier(&vmwdt_power_notifier);
310 if (ret) 315 if (ret)
311 return ret; 316 return ret;
317 /*
318 * misc_register() has to be the last action in module_init(), because
319 * file operations will be available right after this.
320 */
312 ret = misc_register(&vmwdt_dev); 321 ret = misc_register(&vmwdt_dev);
313 if (ret) { 322 if (ret) {
314 unregister_pm_notifier(&vmwdt_power_notifier); 323 unregister_pm_notifier(&vmwdt_power_notifier);