All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: John Kacur <jkacur@redhat.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jan Blunck <jblunck@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown.
Date: Tue, 27 Apr 2010 15:03:17 +0200	[thread overview]
Message-ID: <201004271503.18077.arnd@arndb.de> (raw)
In-Reply-To: <alpine.LFD.2.00.1004271352510.3318@localhost>

On Tuesday 27 April 2010, John Kacur wrote:
> Well it is certainly possible that my fixup is not correct too - your 
> patch cannot be correct, because it doesn't compile! Here is what I get 
> when I apply your patch to a recent linus/master

Ah, I see.

> make O=/bld/arnd/ drivers/media/video/v4l2-dev.o
> -----CUT A BUNCH OF STUFF OUT ---
>   CC      drivers/media/video/v4l2-dev.o
> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c: In function 
> ‘v4l2_ioctl’:
> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: warning: passing 
> argument 1 of ‘vdev->fops->ioctl’ from incompatible pointer type
> /home/jkacur/jk-2.6/drivers/media/video/v4l2-dev.c:230: note: expected 
> ‘struct file *’ but argument is of type ‘struct inode *’

I didn't realize that the prototype for the locked ->ioctl function in
v4l2 does not take the inode argument, so that needs to be dropped from
my patch (i.e. not added).

Or we do it slightly better and clean up the code a bit in the process.

Mauro, does this patch make sense to you? It would be good to have your
Ack so we can queue this in the series leading to the removal of the
->ioctl file operation. We can also do the minimal change and let you
take care of fixing this up in a different way in your own tree.

---
Subject: v4l: convert v4l2-dev to unlocked_ioctl

v4l2 implements two separate file operations for drivers that use locked
and unlocked ioctl callbacks. Since we want to remove the ioctl file operation
in favor of the unlocked variant, this separation no longer seems helpful.

Unfortunately, there are still 77 drivers with locked ioctl functions in
their v4l2_file_operations, which need to be taken care of separately.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/video/v4l2-dev.c |   52 +++++++++++----------------------------
 1 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 7090699..ab198ba 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -25,6 +25,7 @@
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
@@ -215,28 +216,24 @@ 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,
-		unsigned int cmd, unsigned long arg)
+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);
-}
-
-static long v4l2_unlocked_ioctl(struct file *filp,
-		unsigned int cmd, unsigned long arg)
-{
-	struct video_device *vdev = video_devdata(filp);
+	if (vdev->fops->unlocked_ioctl) {
+		ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
+	} else if (vdev->fops->ioctl) {
+		/* TODO: convert all drivers to unlocked_ioctl */
+		lock_kernel();
+		ret = vdev->fops->ioctl(filp, cmd, arg);
+		unlock_kernel();
+	} else 
+		ret = -ENOTTY;
 
-	if (!vdev->fops->unlocked_ioctl)
-		return -ENOTTY;
-	/* 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);
+	return ret;
 }
 
 #ifdef CONFIG_MMU
@@ -307,22 +304,6 @@ static int v4l2_release(struct inode *inode, struct file *filp)
 	return ret;
 }
 
-static const struct file_operations v4l2_unlocked_fops = {
-	.owner = THIS_MODULE,
-	.read = v4l2_read,
-	.write = v4l2_write,
-	.open = v4l2_open,
-	.get_unmapped_area = v4l2_get_unmapped_area,
-	.mmap = v4l2_mmap,
-	.unlocked_ioctl = v4l2_unlocked_ioctl,
-#ifdef CONFIG_COMPAT
-	.compat_ioctl = v4l2_compat_ioctl32,
-#endif
-	.release = v4l2_release,
-	.poll = v4l2_poll,
-	.llseek = no_llseek,
-};
-
 static const struct file_operations v4l2_fops = {
 	.owner = THIS_MODULE,
 	.read = v4l2_read,
@@ -330,7 +311,7 @@ static const struct file_operations v4l2_fops = {
 	.open = v4l2_open,
 	.get_unmapped_area = v4l2_get_unmapped_area,
 	.mmap = v4l2_mmap,
-	.ioctl = v4l2_ioctl,
+	.unlocked_ioctl = v4l2_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = v4l2_compat_ioctl32,
 #endif
@@ -517,10 +498,7 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
 		ret = -ENOMEM;
 		goto cleanup;
 	}
-	if (vdev->fops->unlocked_ioctl)
-		vdev->cdev->ops = &v4l2_unlocked_fops;
-	else
-		vdev->cdev->ops = &v4l2_fops;
+	vdev->cdev->ops = &v4l2_fops;
 	vdev->cdev->owner = vdev->fops->owner;
 	ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1);
 	if (ret < 0) {

  reply	other threads:[~2010-04-27 13:03 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27  9:18 [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes John Kacur
2010-04-27  9:18 ` [PATCH 01/10] dvb: push down BKL into ioctl functions John Kacur
2010-04-27  9:18 ` [PATCH 02/10] scsi: " John Kacur
2010-04-27  9:18 ` [PATCH 03/10] bkl: Fix up compile problems in megaraid from bkl push-down John Kacur
2010-04-27  9:18 ` [PATCH 04/10] bkl: Fix missing inode tw_chrdev_ioctl due to bkl pushdown John Kacur
2010-04-27  9:18 ` [PATCH 05/10] bkl: Fix missing inode in twl_chrdev_ioctl resulting from " John Kacur
2010-04-27  9:18 ` [PATCH 06/10] isdn: push down BKL into ioctl functions John Kacur
2010-04-27  9:18 ` [PATCH 07/10] staging: " John Kacur
2010-04-27  9:18 ` [PATCH 08/10] v4l: always use unlocked_ioctl John Kacur
2010-04-27  9:18 ` [PATCH 09/10] drivers: push down BKL into various drivers John Kacur
2010-04-27  9:18 ` [PATCH 10/10] bkl: Fix-up compile problems as a result of the bkl-pushdown John Kacur
2010-04-27 11:17   ` Arnd Bergmann
2010-04-27 11:54     ` John Kacur
2010-04-27 13:03       ` Arnd Bergmann [this message]
2010-04-28 12:24         ` Mauro Carvalho Chehab
2010-04-28 12:37           ` Hans Verkuil
2010-04-28 12:37             ` Hans Verkuil
2010-04-28 13:02             ` Laurent Pinchart
2010-04-28 14:46               ` Mauro Carvalho Chehab
2010-04-28 14:55         ` Linus Torvalds
2010-04-28 21:52           ` Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 0/5] Pushdown bkl from v4l ioctls Frederic Weisbecker
2010-04-29  6:44             ` Hans Verkuil
2010-04-29  7:10               ` Laurent Pinchart
2010-04-29  7:38                 ` Arnd Bergmann
2010-05-01  9:55                 ` Hans Verkuil
2010-05-01 10:47                   ` Arnd Bergmann
2010-05-01 14:58                   ` Frederic Weisbecker
2010-05-01 11:11               ` Alan Cox
2010-04-29  3:42           ` [PATCH 1/5] v4l: Pushdown bkl into video_ioctl2 Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 2/5] v4l: Use video_ioctl2_unlocked from drivers that don't want the bkl Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 3/5] v4l: Change users of video_ioctl2 to use unlocked_ioctl Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 4/5] v4l: Pushdown bkl to drivers that implement their own ioctl Frederic Weisbecker
2010-04-29  3:42           ` [PATCH 5/5] v4l: Remove struct v4l2_file_operations::ioctl Frederic Weisbecker
2010-04-27 11:31 ` [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes Arnd Bergmann
2010-04-27 12:19   ` John Kacur
2010-04-27 12:41     ` Frederic Weisbecker
2010-04-27 14:24     ` [PATCH 0/6] BKL pushdown into ioctl, continued Arnd Bergmann
2010-04-27 14:24     ` [PATCH 1/7] logfs: push down BKL into ioctl function Arnd Bergmann
2010-04-27 14:32       ` Arnd Bergmann
2010-04-27 14:58       ` Jörn Engel
2010-04-27 15:05         ` Arnd Bergmann
2010-04-27 15:09           ` Jörn Engel
2010-04-27 15:27             ` John Kacur
2010-04-27 15:32               ` Jörn Engel
2010-04-27 15:38                 ` Arnd Bergmann
2010-04-27 20:12                   ` Frederic Weisbecker
2010-04-27 20:30                     ` [PATCH] logfs: kill BKL Arnd Bergmann
2010-05-19 12:51                       ` Frederic Weisbecker
2010-04-27 15:36               ` [PATCH 1/7] logfs: push down BKL into ioctl function Linus Torvalds
2010-04-27 16:29                 ` John Kacur
2010-04-27 19:59       ` Frederic Weisbecker
2010-04-27 14:24     ` [PATCH 2/7] hfsplus: " Arnd Bergmann
2010-04-27 14:24     ` [PATCH 3/7] cris: push down BKL into some device drivers Arnd Bergmann
2010-04-27 17:22       ` Frederic Weisbecker
2010-04-30  7:53       ` Jesper Nilsson
2010-05-17  2:51         ` Frederic Weisbecker
2010-04-27 14:24     ` [PATCH 4/7] sn_hwperf: kill BKL usage Arnd Bergmann
2010-04-27 14:24     ` [PATCH 5/7] um/mmapper: remove " Arnd Bergmann
2010-04-27 14:24     ` [PATCH 6/7] coda/psdev: remove BKL from ioctl function Arnd Bergmann
2010-04-27 14:24     ` [PATCH 7/7] smbfs: push down BKL into " Arnd Bergmann
2010-04-27 12:40   ` [PATCH 00/10] bkl: pushdowns from Arnd, and compile fixes Frederic Weisbecker
2010-04-27 12:51   ` Geert Uytterhoeven
2010-04-28 21:18 ` Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201004271503.18077.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=fweisbec@gmail.com \
    --cc=jblunck@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.