]> err.no Git - linux-2.6/blobdiff - drivers/sbus/char/vfc_dev.c
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6] / drivers / sbus / char / vfc_dev.c
index 9269f7fbd36364957f0cdc97a90357f4e987fd1f..25181bb7d627752de1d4f6932f96d8d4ec2bbb8e 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>
@@ -43,7 +45,7 @@
 #include <asm/vfc_ioctls.h>
 
 static const struct file_operations vfc_fops;
-struct vfc_dev **vfc_dev_lst;
+static struct vfc_dev **vfc_dev_lst;
 static char vfcstr[]="vfc";
 static unsigned char saa9051_init_array[VFC_SAA9051_NR] = {
        0x00, 0x64, 0x72, 0x52,
@@ -52,18 +54,18 @@ static unsigned char saa9051_init_array[VFC_SAA9051_NR] = {
        0x3e
 };
 
-void vfc_lock_device(struct vfc_dev *dev)
+static 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)
+static void vfc_unlock_device(struct vfc_dev *dev)
 {
-       up(&dev->device_lock_sem);
+       mutex_unlock(&dev->device_lock_mtx);
 }
 
 
-void vfc_captstat_reset(struct vfc_dev *dev) 
+static void vfc_captstat_reset(struct vfc_dev *dev)
 {
        dev->control_reg |= VFC_CONTROL_CAPTRESET;
        sbus_writel(dev->control_reg, &dev->regs->control);
@@ -73,7 +75,7 @@ void vfc_captstat_reset(struct vfc_dev *dev)
        sbus_writel(dev->control_reg, &dev->regs->control);
 }
 
-void vfc_memptr_reset(struct vfc_dev *dev) 
+static void vfc_memptr_reset(struct vfc_dev *dev)
 {
        dev->control_reg |= VFC_CONTROL_MEMPTR;
        sbus_writel(dev->control_reg, &dev->regs->control);
@@ -83,7 +85,7 @@ void vfc_memptr_reset(struct vfc_dev *dev)
        sbus_writel(dev->control_reg, &dev->regs->control);
 }
 
-int vfc_csr_init(struct vfc_dev *dev)
+static int vfc_csr_init(struct vfc_dev *dev)
 {
        dev->control_reg = 0x80000000;
        sbus_writel(dev->control_reg, &dev->regs->control);
@@ -105,7 +107,7 @@ int vfc_csr_init(struct vfc_dev *dev)
        return 0;
 }
 
-int vfc_saa9051_init(struct vfc_dev *dev)
+static int vfc_saa9051_init(struct vfc_dev *dev)
 {
        int i;
 
@@ -117,7 +119,7 @@ int vfc_saa9051_init(struct vfc_dev *dev)
        return 0;
 }
 
-int init_vfc_hw(struct vfc_dev *dev) 
+static int init_vfc_hw(struct vfc_dev *dev)
 {
        vfc_lock_device(dev);
        vfc_csr_init(dev);
@@ -130,16 +132,17 @@ int init_vfc_hw(struct vfc_dev *dev)
        return 0; 
 }
 
-int init_vfc_devstruct(struct vfc_dev *dev, int instance) 
+static 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;
 }
 
-int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev, int instance)
+static int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev,
+                          int instance)
 {
        if(dev == NULL) {
                printk(KERN_ERR "VFC: Bogus pointer passed\n");
@@ -166,7 +169,7 @@ int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev, int instance)
 }
 
 
-struct vfc_dev *vfc_get_dev_ptr(int instance) 
+static struct vfc_dev *vfc_get_dev_ptr(int instance)
 {
        return vfc_dev_lst[instance];
 }
@@ -177,14 +180,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 +207,7 @@ static int vfc_open(struct inode *inode, struct file *file)
        vfc_captstat_reset(dev);
        
        vfc_unlock_device(dev);
+       unlock_kernel();
        return 0;
 }
 
@@ -286,7 +293,7 @@ static int vfc_debug(struct vfc_dev *dev, int cmd, void __user *argp)
        return 0;
 }
 
-int vfc_capture_start(struct vfc_dev *dev) 
+static int vfc_capture_start(struct vfc_dev *dev)
 {
        vfc_captstat_reset(dev);
        dev->control_reg = sbus_readl(&dev->regs->control);
@@ -308,7 +315,7 @@ int vfc_capture_start(struct vfc_dev *dev)
        return 0;
 }
 
-int vfc_capture_poll(struct vfc_dev *dev) 
+static int vfc_capture_poll(struct vfc_dev *dev)
 {
        int timeout = 1000;
 
@@ -384,8 +391,8 @@ static int vfc_set_control_ioctl(struct inode *inode, struct file *file,
 }
 
 
-int vfc_port_change_ioctl(struct inode *inode, struct file *file, 
-                         struct vfc_dev *dev, unsigned long arg) 
+static int vfc_port_change_ioctl(struct inode *inode, struct file *file,
+                                struct vfc_dev *dev, unsigned long arg)
 {
        int ret = 0;
        int cmd;
@@ -454,8 +461,8 @@ int vfc_port_change_ioctl(struct inode *inode, struct file *file,
        return ret;
 }
 
-int vfc_set_video_ioctl(struct inode *inode, struct file *file, 
-                       struct vfc_dev *dev, unsigned long arg) 
+static int vfc_set_video_ioctl(struct inode *inode, struct file *file,
+                              struct vfc_dev *dev, unsigned long arg)
 {
        int ret = 0;
        int cmd;
@@ -505,8 +512,8 @@ int vfc_set_video_ioctl(struct inode *inode, struct file *file,
        return ret;
 }
 
-int vfc_get_video_ioctl(struct inode *inode, struct file *file, 
-                       struct vfc_dev *dev, unsigned long arg) 
+static int vfc_get_video_ioctl(struct inode *inode, struct file *file,
+                              struct vfc_dev *dev, unsigned long arg)
 {
        int ret = 0;
        unsigned int status = NO_LOCK;