Merge branch 'timers/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / telephony / phonedev.c
index e41f49a..4d74ba3 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/errno.h>
 #include <linux/phonedev.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
@@ -53,6 +54,7 @@ static int phone_open(struct inode *inode, struct file *file)
        if (minor >= PHONE_NUM_DEVICES)
                return -ENODEV;
 
+       lock_kernel();
        mutex_lock(&phone_lock);
        p = phone_device[minor];
        if (p)
@@ -79,6 +81,7 @@ static int phone_open(struct inode *inode, struct file *file)
        fops_put(old_fops);
 end:
        mutex_unlock(&phone_lock);
+       unlock_kernel();
        return err;
 }
 
@@ -120,14 +123,13 @@ int phone_register_device(struct phone_device *p, int unit)
 void phone_unregister_device(struct phone_device *pfd)
 {
        mutex_lock(&phone_lock);
-       if (phone_device[pfd->minor] != pfd)
-               panic("phone: bad unregister");
-       phone_device[pfd->minor] = NULL;
+       if (likely(phone_device[pfd->minor] == pfd))
+               phone_device[pfd->minor] = NULL;
        mutex_unlock(&phone_lock);
 }
 
 
-static struct file_operations phone_fops =
+static const struct file_operations phone_fops =
 {
        .owner          = THIS_MODULE,
        .open           = phone_open,