]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/saa5249.c
V4L/DVB (8780): v4l: replace the last uses of video_exclusive_open/release
[linux-2.6-omap-h63xx.git] / drivers / media / video / saa5249.c
index fde99d9ee71f5716f7acdcefcc3625a3cc05c7e6..dfd8a9338c55ae7c8f9f6e48651631cc7cfefa74 100644 (file)
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <stdarg.h>
 #include <linux/i2c.h>
 #include <linux/videotext.h>
 #include <linux/videodev.h>
 #include <media/v4l2-common.h>
+#include <media/v4l2-ioctl.h>
 #include <linux/mutex.h>
 
 
@@ -108,6 +110,7 @@ struct saa5249_device
        int disp_mode;
        int virtual_mode;
        struct i2c_client *client;
+       unsigned long in_use;
        struct mutex lock;
 };
 
@@ -629,31 +632,27 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
 static int saa5249_open(struct inode *inode, struct file *file)
 {
        struct video_device *vd = video_devdata(file);
-       struct saa5249_device *t=vd->priv;
-       int err,pgbuf;
+       struct saa5249_device *t = vd->priv;
+       int pgbuf;
 
-       err = video_exclusive_open(inode,file);
-       if (err < 0)
-               return err;
+       if (t->client == NULL)
+               return -ENODEV;
 
-       if (t->client==NULL) {
-               err = -ENODEV;
-               goto fail;
-       }
+       if (test_and_set_bit(0, &t->in_use))
+               return -EBUSY;
 
-       if (i2c_senddata(t, 0, 0, -1) ||                /* Select R11 */
-                                               /* Turn off parity checks (we do this ourselves) */
+       if (i2c_senddata(t, 0, 0, -1) || /* Select R11 */
+               /* Turn off parity checks (we do this ourselves) */
                i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) ||
-                                               /* Display TV-picture, no virtual rows */
-               i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */
-
+               /* Display TV-picture, no virtual rows */
+               i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1))
+               /* Set display to page 4 */
        {
-               err = -EIO;
-               goto fail;
+               clear_bit(0, &t->in_use);
+               return -EIO;
        }
 
-       for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
-       {
+       for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) {
                memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
                memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
                memset(t->vdau[pgbuf].laststat, 0, sizeof(t->vdau[0].laststat));
@@ -664,10 +663,6 @@ static int saa5249_open(struct inode *inode, struct file *file)
        }
        t->virtual_mode = false;
        return 0;
-
- fail:
-       video_exclusive_release(inode,file);
-       return err;
 }
 
 
@@ -675,10 +670,11 @@ static int saa5249_open(struct inode *inode, struct file *file)
 static int saa5249_release(struct inode *inode, struct file *file)
 {
        struct video_device *vd = video_devdata(file);
-       struct saa5249_device *t=vd->priv;
+       struct saa5249_device *t = vd->priv;
+
        i2c_senddata(t, 1, 0x20, -1);           /* Turn off CCT */
        i2c_senddata(t, 5, 3, 3, -1);           /* Turn off TV-display */
-       video_exclusive_release(inode,file);
+       clear_bit(0, &t->in_use);
        return 0;
 }
 
@@ -710,9 +706,7 @@ static const struct file_operations saa_fops = {
 
 static struct video_device saa_template =
 {
-       .owner          = THIS_MODULE,
        .name           = IF_NAME,
-       .type           = VID_TYPE_TELETEXT,    /*| VID_TYPE_TUNER ?? */
        .fops           = &saa_fops,
 };