From patchwork Thu Apr 1 09:23:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 90100 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o319NEKD016417 for ; Thu, 1 Apr 2010 09:23:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753437Ab0DAJXN (ORCPT ); Thu, 1 Apr 2010 05:23:13 -0400 Received: from perceval.irobotique.be ([92.243.18.41]:36547 "EHLO perceval.irobotique.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752993Ab0DAJXM (ORCPT ); Thu, 1 Apr 2010 05:23:12 -0400 Received: from ravenclaw.localnet (unknown [91.182.245.224]) by perceval.irobotique.be (Postfix) with ESMTPSA id A4B9235A06; Thu, 1 Apr 2010 09:23:05 +0000 (UTC) From: Laurent Pinchart To: Hans Verkuil Subject: Re: V4L-DVB drivers and BKL Date: Thu, 1 Apr 2010 11:23:30 +0200 User-Agent: KMail/1.13.1 (Linux/2.6.33; KDE/4.4.1; x86_64; ; ) Cc: linux-media@vger.kernel.org References: <201004011001.10500.hverkuil@xs4all.nl> In-Reply-To: <201004011001.10500.hverkuil@xs4all.nl> MIME-Version: 1.0 Message-Id: <201004011123.31080.laurent.pinchart@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 01 Apr 2010 09:23:14 +0000 (UTC) diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 7090699..14e1b1c 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -215,28 +216,22 @@ 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) -{ - struct video_device *vdev = video_devdata(filp); - - 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); + int 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); + if (vdev->fops->ioctl) { + lock_kernel(); + ret = vdev->fops->ioctl(filp, cmd, arg); + unlock_kernel(); + } else if (vdev->fops->unlocked_ioctl) + ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); + + return ret; } #ifdef CONFIG_MMU @@ -323,22 +318,6 @@ static const struct file_operations v4l2_unlocked_fops = { .llseek = no_llseek, }; -static const struct file_operations v4l2_fops = { - .owner = THIS_MODULE, - .read = v4l2_read, - .write = v4l2_write, - .open = v4l2_open, - .get_unmapped_area = v4l2_get_unmapped_area, - .mmap = v4l2_mmap, - .ioctl = v4l2_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = v4l2_compat_ioctl32, -#endif - .release = v4l2_release, - .poll = v4l2_poll, - .llseek = no_llseek, -}; - /** * get_index - assign stream index number based on parent device * @vdev: video_device to assign index number to, vdev->parent should be assigned @@ -517,10 +496,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_unlocked_fops; vdev->cdev->owner = vdev->fops->owner; ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1); if (ret < 0) {