From patchwork Tue Nov 16 14:22:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 327902 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAGEMCsE006434 for ; Tue, 16 Nov 2010 14:22:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758513Ab0KPOVp (ORCPT ); Tue, 16 Nov 2010 09:21:45 -0500 Received: from moutng.kundenserver.de ([212.227.17.8]:58424 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758501Ab0KPOVo (ORCPT ); Tue, 16 Nov 2010 09:21:44 -0500 Received: from klappe2.localnet (deibp9eh1--blueice3n2.emea.ibm.com [195.212.29.180]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0LsNui-1OKwFt11j6-012Ynj; Tue, 16 Nov 2010 15:21:29 +0100 From: Arnd Bergmann To: "Hans Verkuil" Subject: Re: [RFC PATCH 0/8] V4L BKL removal: first round Date: Tue, 16 Nov 2010 15:22:19 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.35-16-generic; KDE/4.3.2; x86_64; ; ) Cc: "Mauro Carvalho Chehab" , linux-media@vger.kernel.org References: <4CE281E8.3040705@redhat.com> <7d7108eaf1260587bbe2cacf8f5d2db9.squirrel@webmail.xs4all.nl> In-Reply-To: <7d7108eaf1260587bbe2cacf8f5d2db9.squirrel@webmail.xs4all.nl> MIME-Version: 1.0 Message-Id: <201011161522.19758.arnd@arndb.de> X-Provags-ID: V02:K0:hoBWBAQJbkM+SWmTEEXugycp2q4BA8UsEuoYjQqfy/L HQE85VASOgCnH9MroUq1HypOxnVvhy9Y/ac1VTzjguiNUWSfuG 4Mpy3cLjWpcCmgtPdO+CF1HQp0ttDfYOlrSTccV8vTsHMYh+6K OWPyPwQ+uKIzl+QU1ovJ5Qi12xZrazAZJOoArRis8IJAx3Q9au VIi0+PCoEh2UV+wSYyuvw== 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 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Nov 2010 14:22:12 +0000 (UTC) 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 */