From patchwork Sun Sep 25 22:43:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Rankin X-Patchwork-Id: 7949 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1R7xQB-0002Yh-MJ; Mon, 26 Sep 2011 00:44:04 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-1) with esmtp id 1R7xQ9-0002nz-LH; Mon, 26 Sep 2011 00:43:38 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840Ab1IYWnR (ORCPT + 5 others); Sun, 25 Sep 2011 18:43:17 -0400 Received: from nm1-vm0.bt.bullet.mail.ukl.yahoo.com ([217.146.182.223]:41184 "HELO nm1-vm0.bt.bullet.mail.ukl.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752119Ab1IYWnR (ORCPT ); Sun, 25 Sep 2011 18:43:17 -0400 Received: from [217.146.183.196] by nm1.bt.bullet.mail.ukl.yahoo.com with NNFMP; 25 Sep 2011 22:43:15 -0000 Received: from [217.146.183.203] by tm2.bt.bullet.mail.ukl.yahoo.com with NNFMP; 25 Sep 2011 22:43:15 -0000 Received: from [127.0.0.1] by omp1001.bt.mail.ukl.yahoo.com with NNFMP; 25 Sep 2011 22:43:15 -0000 X-Yahoo-Newman-Id: 791940.72779.bm@omp1001.bt.mail.ukl.yahoo.com Received: (qmail 962 invoked from network); 25 Sep 2011 22:43:15 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type; b=jVaX36h+0G6zCU04GiX3dzqRQTxH6kpJnMlIC6XmlbcJuVXk+QMMHLCm/zVQvPhatcnV0AdGb5sYBZMCtFTUiqoCDiHgssLzAYumRAbbSBYzHK2HYHmhgkZh8S/F2UoMJ5LSfCBw3kjqU8/ocl6NARpYXiptab/IUkpRL9qEDNk= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1316990595; bh=iUBGa4bypXiLFlY9NJtUqd40P2nDZJ9RIhs4vXXcru8=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type; b=u1+4HrqDvD3mBLGsnkvM3n0iZzayODtytkUlyqdJjlZtLmD4x+am/GDL6R34oHsqbC4uTTiuJNvQ0RCKhcdZP+Sg2OsZDKUFf03DBtjQdAo65x8/9k/u6ntPzeKI4B2N1WEPxrqT+0SRx+Mco3wyNicn+3CUHpCy18ayB7pgOmI= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Deqyv6YVM1k1NcJOd2JHwB4acy0i0u25d8A.M8P.ZQR1Kbx 6ODwm0q3Js6N5QLIOGsYvFsSfVqYLPyatQjM6806SVjsqk9e0Crde7RC2eX4 _Yc1gpw5HdcnbG0rHDZPqip_d_v2GjwDgO1JhJfRrmeZjOXGhuVh3DsztcUZ gZISiGciWRWVvkFAteykuBm1UQoiwAPi6GIHb0EZgCB7E7M0r50CNWQx2_dn 87f_sjUSPO3VJqJik68oaf5ec9i8LZV7lFX6POUTi6VEaNk.ZVzNo9Wdk.dn 3MOOibKiTTL.70D6RfPMp_C99ibkiR4D83bftLZx3nVN20qLzGA6HVEDXKES qMQFrvDd3JbBvIW2sU3ivg97ApFd4aoexDA1j3gzQ6Acq1Gfa.UeMBHJuhy_ thbGW X-Yahoo-SMTP: dMK34oyswBBlfKesWTI5ovDjFOUFE6shtILt.ZXnUEjQHhWq Received: from wellhouse.underworld (rankincj@86.178.153.128 with login) by smtp820.mail.ukl.yahoo.com with SMTP; 25 Sep 2011 22:43:15 +0000 GMT Received: from volcano.underworld (volcano.underworld [192.168.0.3]) by wellhouse.underworld (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p8PMhC5b030110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 25 Sep 2011 23:43:14 +0100 Message-ID: <4E7FAE80.50802@yahoo.com> Date: Sun, 25 Sep 2011 23:43:12 +0100 From: Chris Rankin User-Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2 MIME-Version: 1.0 To: Mauro Carvalho Chehab CC: linux-media@vger.kernel.org Subject: [PATCH] EM28xx - replug locking cleanup Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.9.25.223017 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' FORGED_FROM_YAHOO 0.1, MIME_TEXT_ONLY_MP_MIXED 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, ECARD_KNOWN_DOMAINS 0, __ANY_URI 0, __BAT_BOUNDARY 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __DOMAINKEYS_YAHOO 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_YAHOO 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' X-LSpam-Score: 1.1 (+) X-LSpam-Report: No, score=1.1 required=5.0 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, KB_DATE_CONTAINS_TAB=2.751, RCVD_IN_DNSWL_MED=-2.3, TAB_IN_FROM=2.494, T_DKIM_INVALID=0.01, T_TVD_MIME_EPI=0.01, UNPARSEABLE_RELAY=0.001 autolearn=no Mauro, This patch simplifies the locking by moving the em28xx_init_extension() call until em28xx_usb_probe() has finished with the dev->lock mutex. It therefore makes the second and subsequent "plugging" events logically identical to the first "plugging" event when the em28xx-dvb and em28xx-alsa modules must be loaded (i.e. registered). Basically, em28xx_usb_probe() requests that em28xx-dvb be loaded and also triggers udev to initialise the V4L2 devices. These two events are serialised by the dev->lock mutex but the order that they happen in is undefined. But this has always been the case anyway. Signed-off-by: Chris Rankin Cheers, Chris --- linux/drivers/media/video/em28xx/em28xx-cards.c.orig 2011-09-25 22:51:59.000000000 +0100 +++ linux/drivers/media/video/em28xx/em28xx-cards.c 2011-09-25 23:24:06.000000000 +0100 @@ -3005,10 +3005,6 @@ goto fail; } - mutex_unlock(&dev->lock); - em28xx_init_extension(dev); - mutex_lock(&dev->lock); - /* Save some power by putting tuner to sleep */ v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0); @@ -3243,6 +3239,13 @@ */ mutex_unlock(&dev->lock); + /* + * These extensions can be modules. If the modules are already + * loaded then we can initialise the device now, otherwise we + * will initialise it when the modules load instead. + */ + em28xx_init_extension(dev); + return 0; err: