Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl
[linux-flexiantxendom0-natty.git] / drivers / char / apm-emulation.c
index 5ffa690..3022801 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/module.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/miscdevice.h>
@@ -126,6 +126,7 @@ struct apm_user {
 /*
  * Local variables
  */
+static DEFINE_MUTEX(apm_mutex);
 static atomic_t suspend_acks_pending = ATOMIC_INIT(0);
 static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0);
 static int apm_disabled;
@@ -274,7 +275,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
        if (!as->suser || !as->writer)
                return -EPERM;
 
-       lock_kernel();
+       mutex_lock(&apm_mutex);
        switch (cmd) {
        case APM_IOC_SUSPEND:
                mutex_lock(&state_lock);
@@ -335,7 +336,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
                mutex_unlock(&state_lock);
                break;
        }
-       unlock_kernel();
+       mutex_unlock(&apm_mutex);
 
        return err;
 }
@@ -370,7 +371,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 {
        struct apm_user *as;
 
-       lock_kernel();
+       mutex_lock(&apm_mutex);
        as = kzalloc(sizeof(*as), GFP_KERNEL);
        if (as) {
                /*
@@ -390,7 +391,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 
                filp->private_data = as;
        }
-       unlock_kernel();
+       mutex_unlock(&apm_mutex);
 
        return as ? 0 : -ENOMEM;
 }