]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/sbus/char/vfc_dev.c
Merge branch 'core/rcu' into core/rcu-for-linus
[linux-2.6-omap-h63xx.git] / drivers / sbus / char / vfc_dev.c
index 26b1d2a17ed2f9f3c15bb03d89d8f2e0739fa60c..1f6cb8ae2784cddaf76aa949033381b271126037 100644 (file)
@@ -22,7 +22,9 @@
 #include <linux/fs.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
@@ -54,12 +56,12 @@ static unsigned char saa9051_init_array[VFC_SAA9051_NR] = {
 
 void vfc_lock_device(struct vfc_dev *dev)
 {
-       down(&dev->device_lock_sem);
+       mutex_lock(&dev->device_lock_mtx);
 }
 
 void vfc_unlock_device(struct vfc_dev *dev)
 {
-       up(&dev->device_lock_sem);
+       mutex_unlock(&dev->device_lock_mtx);
 }
 
 
@@ -133,7 +135,7 @@ int init_vfc_hw(struct vfc_dev *dev)
 int init_vfc_devstruct(struct vfc_dev *dev, int instance) 
 {
        dev->instance=instance;
-       init_MUTEX(&dev->device_lock_sem);
+       mutex_init(&dev->device_lock_mtx);
        dev->control_reg=0;
        dev->busy=0;
        return 0;
@@ -177,14 +179,17 @@ static int vfc_open(struct inode *inode, struct file *file)
 {
        struct vfc_dev *dev;
 
+       lock_kernel();
        spin_lock(&vfc_dev_lock);
        dev = vfc_get_dev_ptr(iminor(inode));
        if (dev == NULL) {
                spin_unlock(&vfc_dev_lock);
+               unlock_kernel();
                return -ENODEV;
        }
        if (dev->busy) {
                spin_unlock(&vfc_dev_lock);
+               unlock_kernel();
                return -EBUSY;
        }
 
@@ -201,6 +206,7 @@ static int vfc_open(struct inode *inode, struct file *file)
        vfc_captstat_reset(dev);
        
        vfc_unlock_device(dev);
+       unlock_kernel();
        return 0;
 }
 
@@ -248,6 +254,7 @@ static int vfc_debug(struct vfc_dev *dev, int cmd, void __user *argp)
                                        buffer,inout.len);
 
                if (copy_to_user(argp,&inout,sizeof(inout))) {
+                       vfc_unlock_device(dev);
                        kfree(buffer);
                        return -EFAULT;
                }