[PATCH v3 3/7] media: verisilicon: h264: Use alloc/free helpers for auxiliary buffers

From: Benjamin Gaignard

Date: Mon Nov 23 2026 - 04:59:39 EST


Simplify and clean up the code by using the helpers.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@xxxxxxxxxxxxx>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>
---
changes in v3:
- As suggested by Philipp do not mask hantro_allocate_aux_buf() returned
value.

drivers/media/platform/verisilicon/hantro_h264.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_h264.c b/drivers/media/platform/verisilicon/hantro_h264.c
index 2414782f1eb6..3da3083182fb 100644
--- a/drivers/media/platform/verisilicon/hantro_h264.c
+++ b/drivers/media/platform/verisilicon/hantro_h264.c
@@ -494,26 +494,23 @@ int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx)

void hantro_h264_dec_exit(struct hantro_ctx *ctx)
{
- struct hantro_dev *vpu = ctx->dev;
struct hantro_h264_dec_hw_ctx *h264_dec = &ctx->h264_dec;
struct hantro_aux_buf *priv = &h264_dec->priv;

- dma_free_coherent(vpu->dev, priv->size, priv->cpu, priv->dma);
+ hantro_free_aux_buf(ctx, priv);
}

int hantro_h264_dec_init(struct hantro_ctx *ctx)
{
- struct hantro_dev *vpu = ctx->dev;
struct hantro_h264_dec_hw_ctx *h264_dec = &ctx->h264_dec;
struct hantro_aux_buf *priv = &h264_dec->priv;
struct hantro_h264_dec_priv_tbl *tbl;
+ int ret;

- priv->cpu = dma_alloc_coherent(vpu->dev, sizeof(*tbl), &priv->dma,
- GFP_KERNEL);
- if (!priv->cpu)
- return -ENOMEM;
+ ret = hantro_allocate_aux_buf(ctx, priv, sizeof(*tbl));
+ if (ret)
+ return ret;

- priv->size = sizeof(*tbl);
tbl = priv->cpu;
memcpy(tbl->cabac_table, h264_cabac_table, sizeof(tbl->cabac_table));

--
2.53.0