@@ -246,12 +246,11 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
mutex_unlock(vdev->lock);
} else if (vdev->fops->ioctl) {
/* TODO: convert all drivers to unlocked_ioctl */
- static DEFINE_MUTEX(v4l2_ioctl_mutex);
-
- mutex_lock(&v4l2_ioctl_mutex);
- if (video_is_registered(vdev))
+ if (video_is_registered(vdev)) {
+ mutex_lock(&vdev->ioctl_lock);
ret = vdev->fops->ioctl(filp, cmd, arg);
- mutex_unlock(&v4l2_ioctl_mutex);
+ mutex_unlock(&vdev->ioctl_lock);
+ }
} else
ret = -ENOTTY;
@@ -507,6 +506,7 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
#endif
vdev->minor = i + minor_offset;
vdev->num = nr;
+ mutex_init(&vdev->ioctl_lock);
devnode_set(vdev);
/* Should not happen since we thought this minor was free */
@@ -97,6 +97,9 @@ struct video_device
/* serialization lock */
struct mutex *lock;
+
+ /* used for the legacy locked ioctl */
+ struct mutex ioctl_lock;
};
/* dev to video-device */