Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp216663pxf; Wed, 17 Mar 2021 03:39:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEXNrmFnbfZ69LSR1QBxxAtdPz6otX1CXU4C4DLDo+rykowOWxTZCtvrVoJEXPnEmjfcHq X-Received: by 2002:aa7:cc98:: with SMTP id p24mr23707252edt.187.1615977572661; Wed, 17 Mar 2021 03:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615977572; cv=none; d=google.com; s=arc-20160816; b=N0d89B6VVMDM/KUVuxD+aWiEIr8QviEG3Lz2ZJ4RhFdxoY9OquStgFSACgm1d1ju4m ezfEyJ/UCWAJs7g6VG8+96c9bTyzt5OVMran/UsXzD0VX9c/Q2jVMyUoPEVkOQVF5WmI Fa9iOqLTDDtn/81G0sOGSNCVzTWha42cLhNxfBgRcvoJwxVu+rzCixxzm3WO3ipD/zzD QEC26bLAPezJBgRlpwJdqJ5em7BhMbtrfYaOh+GOlSloUjFG7Y4AJ9TsTwJThKb0+Ysf 8dAQuNWh9g5O0dodJYU/0gvq6t01FloUI3c+6DVZatKJVXtdUKlGGb8xZrSan/j99aUL Z4cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=VZVA94vcZQUs1b/HuXvvarXkTuyIvnAiDo9ccC8Gd5k=; b=eAYQMGcGNU00grNalQ9AsBa7LxhsNyznmPCZgCQWtYbHvKHU/cQJPEbdNg78A/zbQA 5XZF5fu1RX6sorD2tUvWMzn7ljZtLMc7vUjSDindAOhuF0rW5ptPtSP352kVIlIuqLU4 zUg1PywqCnpIY2nNc71opMJgxK5tieDsaNQAZRfzmt0rXgXJeEIBpu2sB1shkoDczpOM BkfuCakxKlhDY5AFD0R/6uQDCdZ4c98s8j67zCpnWNDqsyKaSc8B9BEqEzb7sVflvFRs bkaNx1quhes7ctyfBP8J3CNaSSrKSPmQ6e4AZg8e0zsuzjOD3m1b8avMAQitB/73eSAK 0GhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s2 header.b=gurBdK5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si13383235edc.327.2021.03.17.03.39.10; Wed, 17 Mar 2021 03:39:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s2 header.b=gurBdK5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230036AbhCQKhA (ORCPT + 99 others); Wed, 17 Mar 2021 06:37:00 -0400 Received: from lb3-smtp-cloud9.xs4all.net ([194.109.24.30]:54739 "EHLO lb3-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbhCQKgh (ORCPT ); Wed, 17 Mar 2021 06:36:37 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id MTXTlA9fKGEYcMTXXlN8Xa; Wed, 17 Mar 2021 11:36:35 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s2; t=1615977395; bh=VZVA94vcZQUs1b/HuXvvarXkTuyIvnAiDo9ccC8Gd5k=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=gurBdK5D9nc6kyHcfcLa6CgHJQaMOxWoNBRHVxUpatdSk0LiDo+Rrz7R98owJPb53 GsddQbOHdGgcPClJdcoN/xVwS1GejgdLA4U6Jipn/tjkaflozy+k6RfF/iiwHjlqHv a1apqp31AYJGjSeySCvl/DTKj53TynAm00fd1hv+6yzSAEA4tKSWdryn8LsQdgEyoF /W91JgqzQge4rzktUpnv6uGhw+2C4B0p4fgxd0qUzFygwHrABGDh8f2XC05oYL7M+P M50qlYAcF/LIsuSbPmDdqAI1Lk2JPYreQYyfy6e5XTsoBFY+P2zdIur4BTK1Z6laPB ewt6p3SIKut/g== Subject: Re: [PATCH v5 01/13] media: v4l2-ioctl: Fix check_ext_ctrls To: Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org Cc: stable@vger.kernel.org References: <20210316180004.1605727-1-ribalda@chromium.org> <20210316180004.1605727-2-ribalda@chromium.org> From: Hans Verkuil Message-ID: <176411ad-97de-ab83-d5f3-1977cadcbcfa@xs4all.nl> Date: Wed, 17 Mar 2021 11:36:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210316180004.1605727-2-ribalda@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfK76AdYDNN2b+tZ16LYeoFrztOE8V/7HovzaQZN6RGV8i33rmJ3aKorCgC5A4D75f7CfQo2dZqy9dC1Q7ZEpqkuthtVQVErxf9iW5cDuty8AKrP7czVy XyXIWs10qD/s2qQH6V9jHC78oqEWxCSOO8cBmO1KE/xfSQcaXFE4jgzH3g7Rg1itcdPXHDCXfXg1Xt/X7zcWGQT8FD4sU9e9YoY+Zbisydj7uVYLHZCn7jdx geY4ZqLQQa0kP4Clvn2nWpt+kgLBZE5Zat+D2K02y7HuWmfLWAxToLGSZB78AmzaMXbsvWWPHsNy/iu+z+p3C+yqB1+o55baNzROqrEl733H8haFwvUyqh/i glbp1BVtcIO7PC9D6tEUyL57qmtxbh2Nd5TCDBcvVg8K0qAoB+D3c8LJ3v4edcnZM59c3fi1SpHMfUQ0Nl9crh0BBkwckgvHMzMuhj50F4FEOU/Z78c= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/03/2021 18:59, Ricardo Ribalda wrote: > Drivers that do not use the ctrl-framework use this function instead. > > - Return error when handling of REQUEST_VAL. > - Do not check for multiple classes when getting the DEF_VAL. > > Fixes v4l2-compliance: > Control ioctls (Input 0): > fail: v4l2-test-controls.cpp(813): doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls) > test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL > > Cc: stable@vger.kernel.org > Fixes: 6fa6f831f095 ("media: v4l2-ctrls: add core request support") > Suggested-by: Hans Verkuil > Signed-off-by: Ricardo Ribalda > Reviewed-by: Laurent Pinchart > --- > drivers/media/v4l2-core/v4l2-ioctl.c | 25 +++++++++++++++++-------- > 1 file changed, 17 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c > index 31d1342e61e8..9406e90ff805 100644 > --- a/drivers/media/v4l2-core/v4l2-ioctl.c > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c > @@ -917,15 +917,24 @@ static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) allow_priv really should be a bool. > for (i = 0; i < c->count; i++) > c->controls[i].reserved2[0] = 0; > > - /* V4L2_CID_PRIVATE_BASE cannot be used as control class > - when using extended controls. > - Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL > - is it allowed for backwards compatibility. > - */ > - if (!allow_priv && c->which == V4L2_CID_PRIVATE_BASE) > - return 0; > - if (!c->which) > + switch (c->which) { > + case V4L2_CID_PRIVATE_BASE: > + /* > + * V4L2_CID_PRIVATE_BASE cannot be used as control class > + * when using extended controls. > + * Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL > + * is it allowed for backwards compatibility. > + */ > + if (!allow_priv) > + return 0; > + break; > + case V4L2_CTRL_WHICH_DEF_VAL: I think it would be better if a second bool 'is_get' argument is added that is true for g_ctrl and g_ext_ctrls: then you can do a 'return is_get;' here. That way drivers do not need to take care of V4L2_CTRL_WHICH_DEF_VAL for set/try. Regards, Hans > + case V4L2_CTRL_WHICH_CUR_VAL: > return 1; > + case V4L2_CTRL_WHICH_REQUEST_VAL: > + return 0; > + } > + > /* Check that all controls are from the same control class. */ > for (i = 0; i < c->count; i++) { > if (V4L2_CTRL_ID2WHICH(c->controls[i].id) != c->which) { >