[PATCH 08/10] v4l: always use unlocked_ioctl

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: John Kacur
Date: Tuesday, April 27, 2010 - 2:18 am

From: Arnd Bergmann <arnd@arndb.de>

v4l drivers may still use a locked ioctl method,
but we now always export an unlocked_ioctl and
lock ourselves, so that the ->ioctl file operation
can get removed.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Fixed merge conflicts that result from having applied
Linus's Preparation for BKL'ed ioctl removal patch first.

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 drivers/media/video/v4l2-dev.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index c48143a..3606694 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -22,6 +22,7 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/errno.h>
+#include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
@@ -215,16 +216,21 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
 	return vdev->fops->poll(filp, poll);
 }
 
-static int v4l2_ioctl(struct inode *inode, struct file *filp,
+static long v4l2_ioctl(struct file *filp,
 		unsigned int cmd, unsigned long arg)
 {
 	struct video_device *vdev = video_devdata(filp);
+	int ret;
 
 	if (!vdev->fops->ioctl)
 		return -ENOTTY;
 	/* Allow ioctl to continue even if the device was unregistered.
 	   Things like dequeueing buffers might still be useful. */
-	return vdev->fops->ioctl(filp, cmd, arg);
+	lock_kernel();
+	ret = vdev->fops->ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
+	unlock_kernel();
+
+	return ret;
 }
 
 static long v4l2_unlocked_ioctl(struct file *filp,
@@ -323,6 +329,11 @@ static const struct file_operations v4l2_unlocked_fops = {
 	.llseek = no_llseek,
 };
 
+/*
+ * Note: this should not be needed, just check
+ *       both pointers in v4l2_ioctl, or kill
+ *       fops->ioctl. -arnd
+ */
 static const struct file_operations v4l2_fops = {
 	.owner = THIS_MODULE,
 	.read = v4l2_read,
@@ -330,7 +341,7 @@ static const struct file_operations v4l2_fops = {
 	.open = v4l2_open,
 	.get_unmapped_area = v4l2_get_unmapped_area,
 	.mmap = v4l2_mmap,
-	.bkl_ioctl = v4l2_ioctl,
+	.unlocked_ioctl = v4l2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = v4l2_compat_ioctl32,
 #endif
-- 
1.6.6.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 08/10] v4l: always use unlocked_ioctl, John Kacur, (Tue Apr 27, 2:18 am)
Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes, Frederic Weisbecker, (Tue Apr 27, 5:40 am)
Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes, Frederic Weisbecker, (Tue Apr 27, 5:41 am)
Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes, Geert Uytterhoeven, (Tue Apr 27, 5:51 am)
[PATCH 0/6] BKL pushdown into ioctl, continued, Arnd Bergmann, (Tue Apr 27, 7:24 am)
[PATCH 1/7] logfs: push down BKL into ioctl function, Arnd Bergmann, (Tue Apr 27, 7:24 am)
[PATCH 2/7] hfsplus: push down BKL into ioctl function, Arnd Bergmann, (Tue Apr 27, 7:24 am)
[PATCH 3/7] cris: push down BKL into some device drivers, Arnd Bergmann, (Tue Apr 27, 7:24 am)
[PATCH 4/7] sn_hwperf: kill BKL usage, Arnd Bergmann, (Tue Apr 27, 7:24 am)
[PATCH 5/7] um/mmapper: remove BKL usage, Arnd Bergmann, (Tue Apr 27, 7:24 am)
[PATCH 6/7] coda/psdev: remove BKL from ioctl function, Arnd Bergmann, (Tue Apr 27, 7:24 am)
[PATCH 7/7] smbfs: push down BKL into ioctl function, Arnd Bergmann, (Tue Apr 27, 7:24 am)
Re: [PATCH 1/7] logfs: push down BKL into ioctl function, Arnd Bergmann, (Tue Apr 27, 7:32 am)
Re: [PATCH 1/7] logfs: push down BKL into ioctl function, Arnd Bergmann, (Tue Apr 27, 8:05 am)
Re: [PATCH 1/7] logfs: push down BKL into ioctl function, Linus Torvalds, (Tue Apr 27, 8:36 am)
Re: [PATCH 1/7] logfs: push down BKL into ioctl function, Arnd Bergmann, (Tue Apr 27, 8:38 am)
Re: [PATCH 3/7] cris: push down BKL into some device drivers, Frederic Weisbecker, (Tue Apr 27, 10:22 am)
Re: [PATCH 1/7] logfs: push down BKL into ioctl function, Frederic Weisbecker, (Tue Apr 27, 12:59 pm)
Re: [PATCH 1/7] logfs: push down BKL into ioctl function, Frederic Weisbecker, (Tue Apr 27, 1:12 pm)
[PATCH] logfs: kill BKL, Arnd Bergmann, (Tue Apr 27, 1:30 pm)
Re: [PATCH 10/10] bkl: Fix-up compile problems as a result ..., Mauro Carvalho Chehab, (Wed Apr 28, 5:24 am)
Re: [PATCH 10/10] bkl: Fix-up compile problems as a result ..., Mauro Carvalho Chehab, (Wed Apr 28, 7:46 am)
Re: [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes, Frederic Weisbecker, (Wed Apr 28, 2:18 pm)
Re: [PATCH 10/10] bkl: Fix-up compile problems as a result ..., Frederic Weisbecker, (Wed Apr 28, 2:52 pm)
[PATCH 0/5] Pushdown bkl from v4l ioctls, Frederic Weisbecker, (Wed Apr 28, 8:42 pm)
[PATCH 1/5] v4l: Pushdown bkl into video_ioctl2, Frederic Weisbecker, (Wed Apr 28, 8:42 pm)
[PATCH 2/5] v4l: Use video_ioctl2_unlocked from drivers th ..., Frederic Weisbecker, (Wed Apr 28, 8:42 pm)
[PATCH 3/5] v4l: Change users of video_ioctl2 to use unloc ..., Frederic Weisbecker, (Wed Apr 28, 8:42 pm)
[PATCH 4/5] v4l: Pushdown bkl to drivers that implement th ..., Frederic Weisbecker, (Wed Apr 28, 8:42 pm)
[PATCH 5/5] v4l: Remove struct v4l2_file_operations::ioctl, Frederic Weisbecker, (Wed Apr 28, 8:42 pm)
Re: [PATCH 0/5] Pushdown bkl from v4l ioctls, Hans Verkuil, (Wed Apr 28, 11:44 pm)
Re: [PATCH 0/5] Pushdown bkl from v4l ioctls, Laurent Pinchart, (Thu Apr 29, 12:10 am)
Re: [PATCH 0/5] Pushdown bkl from v4l ioctls, Arnd Bergmann, (Thu Apr 29, 12:38 am)
Re: [PATCH 3/7] cris: push down BKL into some device drivers, Jesper Nilsson, (Fri Apr 30, 12:53 am)
Re: [PATCH 0/5] Pushdown bkl from v4l ioctls, Hans Verkuil, (Sat May 1, 2:55 am)
Re: [PATCH 0/5] Pushdown bkl from v4l ioctls, Arnd Bergmann, (Sat May 1, 3:47 am)
Re: [PATCH 0/5] Pushdown bkl from v4l ioctls, Alan Cox, (Sat May 1, 4:11 am)
Re: [PATCH 0/5] Pushdown bkl from v4l ioctls, Frederic Weisbecker, (Sat May 1, 7:58 am)
Re: [PATCH 3/7] cris: push down BKL into some device drivers, Frederic Weisbecker, (Sun May 16, 7:51 pm)
Re: [PATCH] logfs: kill BKL, Frederic Weisbecker, (Wed May 19, 5:51 am)