From patchwork Tue May 31 22:24:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Lachowsky X-Patchwork-Id: 834152 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4VMYmYa015673 for ; Tue, 31 May 2011 22:34:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932803Ab1EaWeq (ORCPT ); Tue, 31 May 2011 18:34:46 -0400 Received: from antispam02.maxim-ic.com ([205.153.101.183]:34438 "EHLO antispam02.maxim-ic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932779Ab1EaWep (ORCPT ); Tue, 31 May 2011 18:34:45 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 31 May 2011 22:34:48 +0000 (UTC) X-Greylist: delayed 619 seconds by postgrey-1.27 at vger.kernel.org; Tue, 31 May 2011 18:34:45 EDT X-ASG-Debug-ID: 1306880663-02256b0a4c4002a0001-rVgMWv Received: from maxdalex02.maxim-ic.internal (maxdalex02.maxim-ic.internal [10.16.15.104]) by antispam02.maxim-ic.com with ESMTP id 88fCcQiWKkZqMiQ0; Tue, 31 May 2011 15:24:23 -0700 (PDT) X-Barracuda-Envelope-From: stephan.lachowsky@maxim-ic.com Received: from maxsvlex01.maxim-ic.internal (172.18.47.214) by maxdalex02.maxim-ic.internal (10.16.15.104) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 31 May 2011 17:24:22 -0500 Received: from [10.32.80.201] (10.32.80.201) by maxsvlex01.maxim-ic.internal (172.18.47.214) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 31 May 2011 15:24:22 -0700 Subject: [PATCH] [media] uvcvideo: Fix control mapping for devices with multiple chains From: Stephan Lachowsky X-ASG-Orig-Subj: [PATCH] [media] uvcvideo: Fix control mapping for devices with multiple chains To: Laurent Pinchart CC: "linux-media@vger.kernel.org" , "linux-uvc-devel@lists.berlios.de" Date: Tue, 31 May 2011 15:24:21 -0700 Message-ID: <1306880661.2916.39.camel@svmlwks101> MIME-Version: 1.0 X-Mailer: Evolution 2.32.2 (2.32.2-1.fc14) X-Barracuda-Connect: maxdalex02.maxim-ic.internal[10.16.15.104] X-Barracuda-Start-Time: 1306880663 X-Barracuda-URL: http://192.168.10.183:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at maxim-ic.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.65236 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The search for matching extension units fails to take account of the current chain. In the case where you have two distinct video chains, both containing an XU with the same GUID but different unit ids, you will be unable to perform a mapping on the second chain because entity on the first chain will always be found first Fix this by only searching the current chain when performing a control mapping. This is analogous to the search used by uvc_find_control(), and is the correct behaviour. Signed-off-by: Stephan Lachowsky --- drivers/media/video/uvc/uvc_ctrl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c index 59f8a9a..a77648f 100644 --- a/drivers/media/video/uvc/uvc_ctrl.c +++ b/drivers/media/video/uvc/uvc_ctrl.c @@ -1565,8 +1565,8 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, return -EINVAL; } - /* Search for the matching (GUID/CS) control in the given device */ - list_for_each_entry(entity, &dev->entities, list) { + /* Search for the matching (GUID/CS) control on the current chain */ + list_for_each_entry(entity, &chain->entities, chain) { unsigned int i; if (UVC_ENTITY_TYPE(entity) != UVC_VC_EXTENSION_UNIT ||