]> err.no Git - linux-2.6/blobdiff - drivers/media/video/saa5249.c
V4L/DVB (3569): PATCH: switch cpia2 to mutexes and use ioctl 32 compat lib func
[linux-2.6] / drivers / media / video / saa5249.c
index a51c7bd96618ef767123dfec1b3a923b29fb5520..a9f3cf0b1e3c5b6044586e103627df0f0427d323 100644 (file)
@@ -56,6 +56,8 @@
 #include <linux/i2c.h>
 #include <linux/videotext.h>
 #include <linux/videodev.h>
+#include <linux/mutex.h>
+
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -105,7 +107,7 @@ struct saa5249_device
        int disp_mode;
        int virtual_mode;
        struct i2c_client *client;
-       struct semaphore lock;
+       struct mutex lock;
 };
 
 
@@ -151,21 +153,20 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
         client_template.adapter = adap;
         client_template.addr = addr;
        memcpy(client, &client_template, sizeof(*client));
-       t = kmalloc(sizeof(*t), GFP_KERNEL);
+       t = kzalloc(sizeof(*t), GFP_KERNEL);
        if(t==NULL)
        {
                kfree(client);
                return -ENOMEM;
        }
-       memset(t, 0, sizeof(*t));
        strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
-       init_MUTEX(&t->lock);
+       mutex_init(&t->lock);
        
        /*
         *      Now create a video4linux device
         */
         
-       vd = (struct video_device *)kmalloc(sizeof(struct video_device), GFP_KERNEL);
+       vd = kmalloc(sizeof(struct video_device), GFP_KERNEL);
        if(vd==NULL)
        {
                kfree(t);
@@ -620,9 +621,9 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
        int err;
        
        cmd = vtx_fix_command(cmd);
-       down(&t->lock);
+       mutex_lock(&t->lock);
        err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl);
-       up(&t->lock);
+       mutex_unlock(&t->lock);
        return err;
 }
 
@@ -702,6 +703,7 @@ static struct file_operations saa_fops = {
        .open           = saa5249_open,
        .release        = saa5249_release,
        .ioctl          = saa5249_ioctl,
+       .compat_ioctl   = v4l_compat_ioctl32,
        .llseek         = no_llseek,
 };