]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/c-qcam.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6-omap-h63xx.git] / drivers / media / video / c-qcam.c
index 7f6c6b4bec10e7f3470d8452e1ee71b9cd90ab0e..0f930d35146619fea78c43a0370b6fec6fdaba0f 100644 (file)
@@ -51,6 +51,7 @@ struct qcam_device {
        int contrast, brightness, whitebal;
        int top, left;
        unsigned int bidirectional;
+       unsigned long in_use;
        struct mutex lock;
 };
 
@@ -687,11 +688,28 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
        return len;
 }
 
+static int qcam_exclusive_open(struct inode *inode, struct file *file)
+{
+       struct video_device *dev = video_devdata(file);
+       struct qcam_device *qcam = (struct qcam_device *)dev;
+
+       return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0;
+}
+
+static int qcam_exclusive_release(struct inode *inode, struct file *file)
+{
+       struct video_device *dev = video_devdata(file);
+       struct qcam_device *qcam = (struct qcam_device *)dev;
+
+       clear_bit(0, &qcam->in_use);
+       return 0;
+}
+
 /* video device template */
 static const struct file_operations qcam_fops = {
        .owner          = THIS_MODULE,
-       .open           = video_exclusive_open,
-       .release        = video_exclusive_release,
+       .open           = qcam_exclusive_open,
+       .release        = qcam_exclusive_release,
        .ioctl          = qcam_ioctl,
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = v4l_compat_ioctl32,
@@ -704,6 +722,7 @@ static struct video_device qcam_template=
 {
        .name           = "Colour QuickCam",
        .fops           = &qcam_fops,
+       .release        = video_device_release_empty,
 };
 
 /* Initialize the QuickCam driver control structure. */
@@ -796,7 +815,7 @@ static int init_cqcam(struct parport *port)
        }
 
        printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
-              qcam->vdev.minor, qcam->pport->name);
+              qcam->vdev.num, qcam->pport->name);
 
        qcams[num_cams++] = qcam;