@@ -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
@@ -97,6 +97,8 @@ struct video_device
/* ioctl callbacks */
const struct v4l2_ioctl_ops *ioctl_ops;
+
+ struct mutex *ioctl_lock;
};
/* dev to video-device */