diff mbox

[RFC,0/8] V4L BKL removal: first round

Message ID 201011161522.19758.arnd@arndb.de (mailing list archive)
State Not Applicable
Headers show

Commit Message

Arnd Bergmann Nov. 16, 2010, 2:22 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 03f7f46..5873d12 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -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 */
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 15802a0..e8a8485 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -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 */