aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/apm-emulation.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/apm-emulation.c')
-rw-r--r--drivers/char/apm-emulation.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 033e1505fca9..6a420baea268 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -13,7 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/poll.h> 14#include <linux/poll.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/smp_lock.h> 16#include <linux/mutex.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/seq_file.h> 18#include <linux/seq_file.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
@@ -126,6 +126,7 @@ struct apm_user {
126/* 126/*
127 * Local variables 127 * Local variables
128 */ 128 */
129static DEFINE_MUTEX(apm_mutex);
129static atomic_t suspend_acks_pending = ATOMIC_INIT(0); 130static atomic_t suspend_acks_pending = ATOMIC_INIT(0);
130static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0); 131static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0);
131static int apm_disabled; 132static int apm_disabled;
@@ -274,7 +275,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
274 if (!as->suser || !as->writer) 275 if (!as->suser || !as->writer)
275 return -EPERM; 276 return -EPERM;
276 277
277 lock_kernel(); 278 mutex_lock(&apm_mutex);
278 switch (cmd) { 279 switch (cmd) {
279 case APM_IOC_SUSPEND: 280 case APM_IOC_SUSPEND:
280 mutex_lock(&state_lock); 281 mutex_lock(&state_lock);
@@ -335,7 +336,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
335 mutex_unlock(&state_lock); 336 mutex_unlock(&state_lock);
336 break; 337 break;
337 } 338 }
338 unlock_kernel(); 339 mutex_unlock(&apm_mutex);
339 340
340 return err; 341 return err;
341} 342}
@@ -370,7 +371,7 @@ static int apm_open(struct inode * inode, struct file * filp)
370{ 371{
371 struct apm_user *as; 372 struct apm_user *as;
372 373
373 lock_kernel(); 374 mutex_lock(&apm_mutex);
374 as = kzalloc(sizeof(*as), GFP_KERNEL); 375 as = kzalloc(sizeof(*as), GFP_KERNEL);
375 if (as) { 376 if (as) {
376 /* 377 /*
@@ -390,7 +391,7 @@ static int apm_open(struct inode * inode, struct file * filp)
390 391
391 filp->private_data = as; 392 filp->private_data = as;
392 } 393 }
393 unlock_kernel(); 394 mutex_unlock(&apm_mutex);
394 395
395 return as ? 0 : -ENOMEM; 396 return as ? 0 : -ENOMEM;
396} 397}