[v10,08/54] media: visl: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231003080704.43911-9-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:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928575vqb; Tue, 3 Oct 2023 01:08:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBPeer6GYvT1ffY2wGq3+B26XEnEWDltm7VCTHu/lHzW5iQk4vbUkJqJud/gCKyG6RMY0F X-Received: by 2002:a05:6e02:c6c:b0:351:5b29:8a5a with SMTP id f12-20020a056e020c6c00b003515b298a5amr13382417ilj.27.1696320513370; Tue, 03 Oct 2023 01:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320513; cv=none; d=google.com; s=arc-20160816; b=HNhcOIlbMrhHvVBXP7iqnOIA2frxIM1UtgQZLsUEDUIgTjx9TI2pnPhnwdSHLhlXBM 86RDAuRi34TyoCHYmdCmEYuokNYs2xnltaCGugdY2Ho8lrSYv0eiNWKu384HtZrr9g9Y ZFdh7axFeJiGtA7BTwdoNyRbuCJ3sBMqwcAapbnRhHS40NHug92QhXjxV8eBweCXv6Kb m+kMRsnoPqYDR5IfT0SYXYveG5/8OX+EGTHG8FC8HsUaauTm3WN2P1K9G6oHcvvPsscA lZOjY27+kkfQl62osDveOZnsoD0fK5hAsR/O2tmQXw0jp/8asHq3JWF18SmSKXz1ynkw yS7Q== 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=U2gW/Q+RNn3ntItDX+hvmZgS358f/BD2tGGafv55qEw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=tNJK4aFVmXaNptaKpUrYRgTY5MDOKMinQHIwe04l5Dz103sFQJGNAn/ogtx9S4OlUW uIeXUvGpRY8f2Jtg3GvOikzkLT2eZgYcCvZes6dOBAIl01+G2z9P32pvOqCyS0gXxWLN JmbnrufKilE8XaiN5StG3UbVKX30BJKO/RhNxhz9RsZgi4O5mTBl4OR0nLfbJC+/kQzE yesxYPnf/xiCXcUBlbzx7nSOyPXsvRC7FuBXwIp9R1Jin5ZLF6ifQPv3hDbwXZAKpbkX ADuyC1y/rianh0eFUKB7EO4CF5Mt+mJ2e+4j+2a9vsD/7HJBRldI/2ECHyM9ycZsUFMw wx3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EbF87OCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s190-20020a6377c7000000b00578b9757214si858143pgc.163.2023.10.03.01.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EbF87OCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 69727823FAD7; Tue, 3 Oct 2023 01:08:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239583AbjJCII1 (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Tue, 3 Oct 2023 04:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239296AbjJCIHX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 3 Oct 2023 04:07:23 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BC22B7; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 04B03660731F; Tue, 3 Oct 2023 09:07:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320437; bh=Osy0YWOEVUvzSOYoJm+JBXSigMNkmpw77qpRTwkivks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EbF87OCFiLweOCAVwYBz906D2Uuqqjyo1DaU4a83x1EgCNBTYwy5gZz9qo/htsYON W57dG31ES6IEu4tSZHfFb2XrTxlW38GP3G/vPqnFbMkXZPpOthCVmo4UcsY+HqevuC dm4P7YGzMmwqEw8gqDlZ40AY8yKwG6QTTPTRNsVv2QcFmRoT2KrRTQWQNcNXkp2D0V a95zAmahJKLdZppmq/5VCdP+DbCun9fGwTOaMkoGgQj/1MJHe60hkIUHSHsnZCHMBz MgwUPaqqq5RY4WfMKuf6cT4xxrEF3bniL7aoLIFftCLx5OVDfk909v3YieueYFM85I BkCd9Mdtfi+Sw== 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> Subject: [PATCH v10 08/54] media: visl: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 3 Oct 2023 10:06:17 +0200 Message-Id: <20231003080704.43911-9-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720978673930587 X-GMAIL-MSGID: 1778720978673930587 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Oct. 3, 2023, 8:06 a.m. UTC
Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array.
This could allow to change the type bufs[] field of vb2_buffer structure if
needed.
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.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
drivers/media/test-drivers/visl/visl-dec.c | 28 ++++++++++++++++------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/test-drivers/visl/visl-dec.c index 318d675e5668..ba20ea998d19 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -290,13 +290,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) for (i = 0; i < out_q->num_buffers; i++) { char entry[] = "index: %u, state: %s, request_fd: %d, "; u32 old_len = len; - char *q_status = visl_get_vb2_state(out_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(out_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, entry, i, q_status, - to_vb2_v4l2_buffer(out_q->bufs[i])->request_fd); + to_vb2_v4l2_buffer(vb2)->request_fd); - len += visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]), + len += visl_fill_bytesused(to_vb2_v4l2_buffer(vb2), &buf[len], TPG_STR_BUF_SZ - len); @@ -342,13 +349,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) len = 0; for (i = 0; i < cap_q->num_buffers; i++) { u32 old_len = len; - char *q_status = visl_get_vb2_state(cap_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(cap_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, "index: %u, status: %s, timestamp: %llu, is_held: %d", - cap_q->bufs[i]->index, q_status, - cap_q->bufs[i]->timestamp, - to_vb2_v4l2_buffer(cap_q->bufs[i])->is_held); + vb2->index, q_status, + vb2->timestamp, + to_vb2_v4l2_buffer(vb2)->is_held); tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]); frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]);