From patchwork Wed Feb 7 01:48:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10204457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A7A66020F for ; Wed, 7 Feb 2018 01:49:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A59628D86 for ; Wed, 7 Feb 2018 01:49:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EC4728D88; Wed, 7 Feb 2018 01:49:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B147E28D86 for ; Wed, 7 Feb 2018 01:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752650AbeBGBtC (ORCPT ); Tue, 6 Feb 2018 20:49:02 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:37546 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753251AbeBGBs6 (ORCPT ); Tue, 6 Feb 2018 20:48:58 -0500 Received: by mail-pl0-f65.google.com with SMTP id ay8so2482562plb.4 for ; Tue, 06 Feb 2018 17:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k5QQejC/l9U0UjknSDYMlHsDRTULxmcaBcn+vZczUZA=; b=KQev5v8Gib6ozV/hWG55O7TlbjCENIhUfhugUrJO1j63r3/JWVGHhbGgSK5mbaD0if 09IQ3CB1kYo7gvMVouGy+NNfEVuip+UX4iBo5dY5JEZnn3EY5VTYdcJmg1Vk4w6DikQa ltdJwWv4S4xai2Gp65luTwceMlIbS18R2xf9U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k5QQejC/l9U0UjknSDYMlHsDRTULxmcaBcn+vZczUZA=; b=Opuo8haihiCwSoK5J+sAM/qOvojfBJS3/VcLneN6CdtAlWeTI6DG4WaIccBQCTiofa v2/GgBYxwkh+rtw+Z+dhV3hW8hYj7dREnZHA2iKjP9JnzyaB5wPqMOoM8bLz5hS7D4vB dpZnX1fFDN86zkja73dpexjg4gJpUpxGRGvGIHL1hWIURd/ZKGUbe4IC9jcdtaAjF5Qk 80fwnkXZbMFLuyds0KWcY2i6P32pXKHXAEO6N6T+3IIXYG1f9+L/Yh0Tc86UZmiXmkBp JtBVrurn5j2Xap5IwLqen0CjsXBhLJqyq4llLpiuN4AbrBOzNxDa8KBxc4/5rVY7sTfF 05wA== X-Gm-Message-State: APf1xPCWTtGDQCP5jWKA8mXApWjnxU7yV5MiNWxw5IatXegVk15cB/NI 1Qf+ScEFMj0WEw2QHCy41CbCvA== X-Google-Smtp-Source: AH8x227OVhDNZgW/9caussKBP2uOUnDis2dkhwfHtA+hgHEvU1WL1Dhr5rTGzPcW5eUmwAWaMiiuaA== X-Received: by 2002:a17:902:b605:: with SMTP id b5-v6mr4378003pls.318.1517968137839; Tue, 06 Feb 2018 17:48:57 -0800 (PST) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:1002:a6cd:a898:e07b:a331]) by smtp.gmail.com with ESMTPSA id x26sm528060pfi.141.2018.02.06.17.48.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 17:48:57 -0800 (PST) From: Alexandre Courbot To: Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Pawel Osciak , Marek Szyprowski , Tomasz Figa , Sakari Ailus , Gustavo Padovan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Alexandre Courbot Subject: [RFCv3 09/17] v4l2-ctrls: use ref in helper instead of ctrl Date: Wed, 7 Feb 2018 10:48:13 +0900 Message-Id: <20180207014821.164536-10-acourbot@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180207014821.164536-1-acourbot@chromium.org> References: <20180207014821.164536-1-acourbot@chromium.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil The next patch needs the reference to a control instead of the control itself, so change struct v4l2_ctrl_helper accordingly. Signed-off-by: Hans Verkuil Signed-off-by: Alexandre Courbot --- drivers/media/v4l2-core/v4l2-ctrls.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index c692a6d925c6..9090a49eef91 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -37,8 +37,8 @@ struct v4l2_ctrl_helper { /* Pointer to the control reference of the master control */ struct v4l2_ctrl_ref *mref; - /* The control corresponding to the v4l2_ext_control ID field. */ - struct v4l2_ctrl *ctrl; + /* The control ref corresponding to the v4l2_ext_control ID field. */ + struct v4l2_ctrl_ref *ref; /* v4l2_ext_control index of the next control belonging to the same cluster, or 0 if there isn't any. */ u32 next; @@ -2856,6 +2856,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, ref = find_ref_lock(hdl, id); if (ref == NULL) return -EINVAL; + h->ref = ref; ctrl = ref->ctrl; if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) return -EINVAL; @@ -2878,7 +2879,6 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, } /* Store the ref to the master control of the cluster */ h->mref = ref; - h->ctrl = ctrl; /* Initially set next to 0, meaning that there is no other control in this helper array belonging to the same cluster */ @@ -2963,7 +2963,7 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs cs->error_idx = cs->count; for (i = 0; !ret && i < cs->count; i++) - if (helpers[i].ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) + if (helpers[i].ref->ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) ret = -EACCES; for (i = 0; !ret && i < cs->count; i++) { @@ -2998,7 +2998,7 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs do { ret = ctrl_to_user(cs->controls + idx, - helpers[idx].ctrl); + helpers[idx].ref->ctrl); idx = helpers[idx].next; } while (!ret && idx); } @@ -3137,7 +3137,7 @@ static int validate_ctrls(struct v4l2_ext_controls *cs, cs->error_idx = cs->count; for (i = 0; i < cs->count; i++) { - struct v4l2_ctrl *ctrl = helpers[i].ctrl; + struct v4l2_ctrl *ctrl = helpers[i].ref->ctrl; union v4l2_ctrl_ptr p_new; cs->error_idx = i; @@ -3249,7 +3249,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, do { /* Check if the auto control is part of the list, and remember the new value. */ - if (helpers[tmp_idx].ctrl == master) + if (helpers[tmp_idx].ref->ctrl == master) new_auto_val = cs->controls[tmp_idx].value; tmp_idx = helpers[tmp_idx].next; } while (tmp_idx); @@ -3262,7 +3262,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, /* Copy the new caller-supplied control values. user_to_new() sets 'is_new' to 1. */ do { - struct v4l2_ctrl *ctrl = helpers[idx].ctrl; + struct v4l2_ctrl *ctrl = helpers[idx].ref->ctrl; ret = user_to_new(cs->controls + idx, ctrl); if (!ret && ctrl->is_ptr) @@ -3278,7 +3278,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, idx = i; do { ret = new_to_user(cs->controls + idx, - helpers[idx].ctrl); + helpers[idx].ref->ctrl); idx = helpers[idx].next; } while (!ret && idx); }