diff mbox

RFC: BKL, locking and ioctls

Message ID 201009191229.35800.hverkuil@xs4all.nl (mailing list archive)
State RFC
Headers show

Commit Message

Hans Verkuil Sept. 19, 2010, 10:29 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 30461cf..44c37e5 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -236,12 +236,18 @@  static long v4l2_unlocked_ioctl(struct file *filp,
                unsigned int cmd, unsigned long arg)
 {
        struct video_device *vdev = video_devdata(filp);
+       int ret;
 
        if (!vdev->fops->unlocked_ioctl)
                return -ENOTTY;
+       if (vdev->ioctl_lock)
+               mutex_lock(vdev->ioctl_lock);
        /* Allow ioctl to continue even if the device was unregistered.
           Things like dequeueing buffers might still be useful. */
-       return vdev->fops->unlocked_ioctl(filp, cmd, arg);
+       ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
+       if (vdev->ioctl_lock)
+               mutex_unlock(vdev->ioctl_lock);
+       return ret;
 }
 
 #ifdef CONFIG_MMU
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 1efcacb..e1ad38a 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -97,6 +97,8 @@  struct video_device
 
        /* ioctl callbacks */
        const struct v4l2_ioctl_ops *ioctl_ops;
+
+       struct mutex *ioctl_lock;
 };
 
 /* dev to video-device */