V4L/DVB (10138): v4l2-ioctl: change to long return type to match unlocked_ioctl.
[safe/jmp/linux-2.6] / drivers / media / video / w9966.c
index 9402f40..038ff32 100644 (file)
@@ -113,6 +113,7 @@ struct w9966_dev {
        signed char contrast;
        signed char color;
        signed char hue;
+       unsigned long in_use;
 };
 
 /*
@@ -179,25 +180,37 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data);
 static int w9966_i2c_rbyte(struct w9966_dev* cam);
 #endif
 
-static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
+static long w9966_v4l_ioctl(struct file *file,
                           unsigned int cmd, unsigned long arg);
 static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
                              size_t count, loff_t *ppos);
 
-static const struct file_operations w9966_fops = {
+static int w9966_exclusive_open(struct file *file)
+{
+       struct w9966_dev *cam = video_drvdata(file);
+
+       return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0;
+}
+
+static int w9966_exclusive_release(struct file *file)
+{
+       struct w9966_dev *cam = video_drvdata(file);
+
+       clear_bit(0, &cam->in_use);
+       return 0;
+}
+
+static const struct v4l2_file_operations w9966_fops = {
        .owner          = THIS_MODULE,
-       .open           = video_exclusive_open,
-       .release        = video_exclusive_release,
+       .open           = w9966_exclusive_open,
+       .release        = w9966_exclusive_release,
        .ioctl          = w9966_v4l_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl   = v4l_compat_ioctl32,
-#endif
        .read           = w9966_v4l_read,
-       .llseek         = no_llseek,
 };
 static struct video_device w9966_template = {
        .name           = W9966_DRIVERNAME,
        .fops           = &w9966_fops,
+       .release        = video_device_release_empty,
 };
 
 /*
@@ -332,9 +345,9 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
 
 // Fill in the video_device struct and register us to v4l
        memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device));
-       cam->vdev.priv = cam;
+       video_set_drvdata(&cam->vdev, cam);
 
-       if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1)
+       if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) < 0)
                return -1;
 
        w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV);
@@ -710,11 +723,9 @@ static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data)
  *     Video4linux interfacing
  */
 
-static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
-                             unsigned int cmd, void *arg)
+static long w9966_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 {
-       struct video_device *vdev = video_devdata(file);
-       struct w9966_dev *cam = vdev->priv;
+       struct w9966_dev *cam = video_drvdata(file);
 
        switch(cmd)
        {
@@ -862,18 +873,17 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
        return 0;
 }
 
-static int w9966_v4l_ioctl(struct inode *inode, struct file *file,
+static long w9966_v4l_ioctl(struct file *file,
                           unsigned int cmd, unsigned long arg)
 {
-       return video_usercopy(inode, file, cmd, arg, w9966_v4l_do_ioctl);
+       return video_usercopy(file, cmd, arg, w9966_v4l_do_ioctl);
 }
 
 // Capture data
 static ssize_t w9966_v4l_read(struct file *file, char  __user *buf,
                              size_t count, loff_t *ppos)
 {
-       struct video_device *vdev = video_devdata(file);
-       struct w9966_dev *cam = vdev->priv;
+       struct w9966_dev *cam = video_drvdata(file);
        unsigned char addr = 0xa0;      // ECP, read, CCD-transfer, 00000
        unsigned char __user *dest = (unsigned char __user *)buf;
        unsigned long dleft = count;