From patchwork Wed Jan 31 10:24:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10193811 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 30891603EE for ; Wed, 31 Jan 2018 10:26:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEABA251F4 for ; Wed, 31 Jan 2018 10:25:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2E3525223; Wed, 31 Jan 2018 10:25:59 +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=unavailable 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 6B50023B32 for ; Wed, 31 Jan 2018 10:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752342AbeAaKZp (ORCPT ); Wed, 31 Jan 2018 05:25:45 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:42888 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753356AbeAaKZ2 (ORCPT ); Wed, 31 Jan 2018 05:25:28 -0500 Received: by mail-pf0-f195.google.com with SMTP id b25so12136482pfd.9 for ; Wed, 31 Jan 2018 02:25:27 -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=T1vbLE7eiUwlL2KAQOBZvMDc/jRNytxCDa322M2q6Tg=; b=S/e52AVAOMAOZOwbf70Bau3dKwRdCwTpKbyZoNv/OT9YFKXe/ksVwlvvVRx7VbjLCK qniqfVeRuIUS6q7VEBYqRbRW9ID3/oHO2Yp4g1hiCLHvo7qH954sEdanZn4uI5jt5n5W /UES0joi5p2CdS86t2FOeEHLqMItXzGjCvotg= 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=T1vbLE7eiUwlL2KAQOBZvMDc/jRNytxCDa322M2q6Tg=; b=dNfs1osjfLZ+BWv6LC4XM8X61PvY9i2c1H6rEHpjaHi1ogeqFvwNB3Qts9rZFP9eYR gSnmNODNUsjmL8cS06jJsz02BT6KnhaawddjQBoNRYuMIFwlUAXY5f7i/zkJ39dnQ52L eIJIhHbyKJY2hIS2xJWMtux4zTer6P7yT4AiqHdOxKA9s+AhmrUbJDRfPotCunaKcK2c GYwqpNbBve//KhfrFSTaqGoPjhbBYPuVCs2rG505XVBCG/7W9EDu+gO4We2/K+nl7Zf1 iPRBmAsXidxaOZNYwZRahcb7LeuyxrPt/YN3aTF4HgUG5KrvPHDYFsVhtzKnlOV2XkoY EiNw== X-Gm-Message-State: AKwxytfsWuaL3LyCIg+ta64H0q3yF0UrwXwtU2hZoHXfsnfLfPTeUo8D QaEfHZDNBb+BrEAzTnc2T/boMg== X-Google-Smtp-Source: AH8x224VJKi3pNnLzYNywNyM2+FqTGK4M/pWH83d0RShY7y8me9ogrNcK8jU5s5lY3nfI+Ttaqijhg== X-Received: by 10.98.248.1 with SMTP id d1mr33224098pfh.222.1517394327549; Wed, 31 Jan 2018 02:25:27 -0800 (PST) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:1002:a6cd:a898:e07b:a331]) by smtp.gmail.com with ESMTPSA id 63sm45301239pft.11.2018.01.31.02.25.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 02:25:27 -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: [RFCv2 09/17] v4l2-ctrls: use ref in helper instead of ctrl Date: Wed, 31 Jan 2018 19:24:27 +0900 Message-Id: <20180131102427.207721-10-acourbot@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180131102427.207721-1-acourbot@chromium.org> References: <20180131102427.207721-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 ca4c320f64c9..0fa20c89ece1 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; @@ -2852,6 +2852,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; @@ -2874,7 +2875,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 */ @@ -2959,7 +2959,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++) { @@ -2994,7 +2994,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); } @@ -3133,7 +3133,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; @@ -3245,7 +3245,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); @@ -3258,7 +3258,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) @@ -3274,7 +3274,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); }