]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/bw-qcam.c
Merge branch 'fixes' into for-linus
[linux-2.6-omap-h63xx.git] / drivers / media / video / bw-qcam.c
index 6e39e253ce5361a5d99644e7b93d96474759b966..ace4ff9ea023b69732568db94093fbf3396682ae 100644 (file)
@@ -495,7 +495,7 @@ static void qc_set(struct qcam_device *q)
                val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
                    q->transfer_scale;
        }
-       val = (val + val2 - 1) / val2;
+       val = DIV_ROUND_UP(val, val2);
        qc_command(q, 0x13);
        qc_command(q, val);
 
@@ -651,7 +651,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
        transperline = q->width * q->bpp;
        divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
            q->transfer_scale;
-       transperline = (transperline + divisor - 1) / divisor;
+       transperline = DIV_ROUND_UP(transperline, divisor);
 
        for (i = 0, yield = yieldlines; i < linestotrans; i++)
        {
@@ -894,10 +894,27 @@ 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;
+}
+
 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,
@@ -909,6 +926,7 @@ static struct video_device qcam_template=
 {
        .name           = "Connectix Quickcam",
        .fops           = &qcam_fops,
+       .release        = video_device_release_empty,
 };
 
 #define MAX_CAMS 4