[v9,08/53] media: visl: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231002120617.119602-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 in14csp1712585vqb; Mon, 2 Oct 2023 14:58:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuHqaSSjNSi1j4aE8E0HCxhrv80W6VIvlwHxzy4EFlIXPtc0fdl7j1R4nKs1K05mJ9ERug X-Received: by 2002:a05:6a00:808:b0:692:ad93:e852 with SMTP id m8-20020a056a00080800b00692ad93e852mr14112227pfk.2.1696283927996; Mon, 02 Oct 2023 14:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696283927; cv=none; d=google.com; s=arc-20160816; b=Ctz5NYwlVuziPkYaxTo9TxH3o+mfHJvmrBOIK6M5lyP24tWH84WWgV5ecbX2LjmUep xcQ9ERGo6/ge5z5Zlk5EzuwsEyhHZqn27R9dSf8rF5LIR1pV0qbvFPhvqo+HsHbKjuQz JDrKjXyBTlU6OpCIUXJKRoo/6QPtI4lHtgUSpy7IGs04tsjiHuCCfcJPtjUncsoiqGSV p9eOKzBFHlrQouZxfx6ATPlAduio4WpG08L53eVt4sFgdkMd9SD/n2nioQvNmQwLji2G bAWkDpP7OZ8IZQ6zmdrq+GwXCMq5zaf5fXQjFotVh2Aab2rFJJdk9c/fjOsvGYKEt16A 8Z9A== 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=FRWNOeVLfOXssKdcdpv+zdP+K6gglMFspTMLIAhPHgAUIyx51c2FMmWXl7vVpIJPyU bknOE4NLlqnacGO6+2DkyPQBsAI1Wi3bljbHIJDsgxtL9knFg0gO9sTNjVGQMzgPaQQ0 RzRoBruVwS6SOoE8sVnlRnyw1vLTevltN9MjIXdLflYRBEOybhUgdshocQ6w+gd1Bk4q KM/7KVzA5ShQgeZqJ2tkYIhnx/BTtPzzVKXCRtv/GykA4P7sIKoEfAZfPue35L9akLBy +aNk76MJSK05DXf7DYk33iFBK+2rVgb766RtdOiPOjP6dUo3e2qcVh5+BC1KdbgLXkBz PGTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NogZwj8n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id cw8-20020a056a00450800b0068fea05ecd7si28233889pfb.164.2023.10.02.14.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 14:58:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NogZwj8n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 907908129AFB; Mon, 2 Oct 2023 05:07:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237087AbjJBMG6 (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Mon, 2 Oct 2023 08:06:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236983AbjJBMGd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 2 Oct 2023 08:06:33 -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 40B30DC; Mon, 2 Oct 2023 05:06:30 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:9537:67ca:c85e:d0ae]) (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 A8ECE660731E; Mon, 2 Oct 2023 13:06:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696248389; bh=Osy0YWOEVUvzSOYoJm+JBXSigMNkmpw77qpRTwkivks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NogZwj8nDLG1OjgXAWYcYVBXvlFevYzFlkL5BiVLUIlAexAoyAZpO6Gey8okj7Aa0 6e8g03i6vAi1Z8ZRTCa3CbHPQRvtuJmEI2/tvqrBwJyefOmgHK22Y0Auk2LVUi/Z0n G17aMnxjcPxRO6P86fuDSGdBMmSFU5xvvybG44Xg92hhwTtJJYMUl422fLWyarDKvs ZyIhEO8F3uil4FIVdkxWQ+yHR7T5f1uXdpuGmzj7PVafsjReTBQlyJb28T8Vf5pDbE Q6YhP/+BleUtnWI3QLpl0alqghVxPMalnF8wOmgTLL/wcI0UfDCJdatKp35H8llcVX 7UbtXWokT0ebA== 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 v9 08/53] media: visl: Use vb2_get_buffer() instead of directly access to buffers array Date: Mon, 2 Oct 2023 14:05:32 +0200 Message-Id: <20231002120617.119602-9-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231002120617.119602-1-benjamin.gaignard@collabora.com> References: <20231002120617.119602-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,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 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 05:07:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778682615766072162 X-GMAIL-MSGID: 1778682615766072162 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Oct. 2, 2023, 12:05 p.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]);