[v13,14/56] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231019125222.21370-15-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp360338vqb; Thu, 19 Oct 2023 05:56:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpqlPw5cXlOp4zmQv6E+Gk5A3BROx4AS2kK4Ex8zjZbSSh0DqB3Prb//6dV3i6w6rTsog4 X-Received: by 2002:a05:6a20:9190:b0:163:9f1d:b464 with SMTP id v16-20020a056a20919000b001639f1db464mr2365320pzd.5.1697720171707; Thu, 19 Oct 2023 05:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697720171; cv=none; d=google.com; s=arc-20160816; b=M2GX98L4BECZ8+dO1zvM5h4EcnhFtK6niWPVpeTCSvQv0FVX6dovn+UuxCG5P+VOg6 U4VQQs1rvYVJ0yxka+0YnuVi/DBQ+6Culk10sbBEtQZB3rk/B9RBPcPFxvkD0C/t011A DG3foMMU8pr53SNIGW7/HaDnt+a7diDMibVIQYrVTJ9LPkbD66VPwXBYnoyAsaVe7r56 kxS/3/Pfiv4llE3eXCQJtgLuqjRGY0WN1O3vGSdKq/C3dlv6KbUIJj4q888cSQBpzdF/ CHtZARId2ZSRSdZhqHJMwbL5BEnCkKlIMPCUnzKgL3YRh1tLn3U2UZFDCD5V7Oc1dSZi PsrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ARXOSBKGUUPDwevHrxoh+LOz0HRWiSJssojf7QO4Re0=; fh=NPTCYP6kV89VhZcTyqjnuKz2OW5UZUbu4oezKHT17AA=; b=mBxTItB071etk50rIr23nqJudD9UzSRGbWKDGHC1C/NMOC52Y/6G4mMdnCtX/HfooR cPVtAf3bztaPGr/9oFHdHiih54V1aem1wJYZyZiy4D4QL1pacAGyYuuHJXqOw3WxPl/b q73V6vhuehQ6xIAi+TaoqESbYTdHlXP3UZpPD4kwPoYAMnhD2PgttPocekBG9mkwheFs evE/OIjk/YWbyFxPwIpXQlA5ayR+jkCWeeV9cfwXGwtOTQAllYjJDB3hxS5gXqLaaHiL BFCxKoWNfr5QOFUyz6FY5AEBAHKF00Sy5jcdL+3c7b99G99Ggd6X0ui5Oq7P9kPojeiO aQtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="a/iBP9tI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id nn18-20020a17090b38d200b00274d3f62044si558097pjb.111.2023.10.19.05.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:56:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="a/iBP9tI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9E93F83762EF; Thu, 19 Oct 2023 05:55:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346025AbjJSMyh (ORCPT <rfc822;lkml4gm@gmail.com> + 25 others); Thu, 19 Oct 2023 08:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345780AbjJSMwp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 19 Oct 2023 08:52:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C23C106; Thu, 19 Oct 2023 05:52:39 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:ccea:1fb5:34eb:239b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id C283F6607351; Thu, 19 Oct 2023 13:52:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697719958; bh=6OByUfiYmown+37pp4jYIRU8BDesYsod95qP0wK3edE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/iBP9tI59PpwPQ9dsu1USfyNb+IVCYoCR90qa9XiqxLyHgD0yUIGidTF5m93xFk+ QwXu68MSX/tZOufr8Ia91h24G1wkP+3l/Xkz9KrFi91jjqOfrcHS83f8+3PC10ft5E TE++zp/l82sxexjgmNkeYAsRFTbnN4UcNUpbv+Q2BsvhZi6nDlSNPHBG/E3tomc/ag wzB4rK/+SeVQRrzRkQlE8jvrEHR34uq+6Jz3Wjsh02oJcS+VYc0Sl0GROv2xlyUVS+ 9VYfyu6jz7+tF4H2ZIUGxjjSYFwhvITG/517mbqZmaMWIsrH/9/Jzv2sLoMxjIz8s4 D7KWWiQDtfhcQ== From: Benjamin Gaignard <benjamin.gaignard@collabora.com> To: mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Jean-Christophe Trotin <jean-christophe.trotin@foss.st.com> Subject: [PATCH v13 14/56] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 19 Oct 2023 14:51:40 +0200 Message-Id: <20231019125222.21370-15-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019125222.21370-1-benjamin.gaignard@collabora.com> References: <20231019125222.21370-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:55:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780188626837935852 X-GMAIL-MSGID: 1780188626837935852 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Oct. 19, 2023, 12:51 p.m. UTC
Use vb2_get_buffer() instead of direct access to the vb2_queue bufs array.
This allows us to change the type of the bufs in the future.
After each call to vb2_get_buffer() we need to be sure that we get
a valid pointer so check the return value of all of them.
Remove index range test since it is done by vb2_get_buffer().
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
CC: Jean-Christophe Trotin <jean-christophe.trotin@foss.st.com>
---
drivers/media/platform/st/sti/hva/hva-v4l2.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c index 3a848ca32a0e..cfe83e9dc01b 100644 --- a/drivers/media/platform/st/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c @@ -569,14 +569,11 @@ static int hva_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) struct vb2_buffer *vb2_buf; vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, buf->type); - - if (buf->index >= vq->num_buffers) { - dev_dbg(dev, "%s buffer index %d out of range (%d)\n", - ctx->name, buf->index, vq->num_buffers); + vb2_buf = vb2_get_buffer(vq, buf->index); + if (!vb2_buf) { + dev_dbg(dev, "%s buffer index %d not found\n", ctx->name, buf->index); return -EINVAL; } - - vb2_buf = vb2_get_buffer(vq, buf->index); stream = to_hva_stream(to_vb2_v4l2_buffer(vb2_buf)); stream->bytesused = buf->bytesused; }