Merge branch 'cpus4096-for-linus-3' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / media / video / bw-qcam.c
index 6e39e25..10dbd4a 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++)
        {
@@ -706,8 +706,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
  *     Video4linux interfacing
  */
 
-static int qcam_do_ioctl(struct inode *inode, struct file *file,
-                        unsigned int cmd, void *arg)
+static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 {
        struct video_device *dev = video_devdata(file);
        struct qcam_device *qcam=(struct qcam_device *)dev;
@@ -864,10 +863,10 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
        return 0;
 }
 
-static int qcam_ioctl(struct inode *inode, struct file *file,
+static long qcam_ioctl(struct file *file,
                     unsigned int cmd, unsigned long arg)
 {
-       return video_usercopy(inode, file, cmd, arg, qcam_do_ioctl);
+       return video_usercopy(file, cmd, arg, qcam_do_ioctl);
 }
 
 static ssize_t qcam_read(struct file *file, char __user *buf,
@@ -894,21 +893,35 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
        return len;
 }
 
-static const struct file_operations qcam_fops = {
+static int qcam_exclusive_open(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 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 v4l2_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,
-#endif
        .read           = qcam_read,
-       .llseek         = no_llseek,
 };
 static struct video_device qcam_template=
 {
        .name           = "Connectix Quickcam",
        .fops           = &qcam_fops,
+       .release        = video_device_release_empty,
 };
 
 #define MAX_CAMS 4