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

From: Nicolas Dufresne

Date: Mon Nov 23 2026 - 14:15:22 EST


Le lundi 23 novembre 2026 à 10:59 +0100, Benjamin Gaignard a écrit :
> Simplify and clean up the code by using the helpers.

I'll pick the series, just wanted to mention that I will edit your subject line
from mpeg4 to mpeg2.

Nicolas

>
> 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.
>
> .../media/platform/verisilicon/hantro_mpeg2.c | 19 ++-----------------
> 1 file changed, 2 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/media/platform/verisilicon/hantro_mpeg2.c b/drivers/media/platform/verisilicon/hantro_mpeg2.c
> index 04e545eb0a83..7386cc50b11b 100644
> --- a/drivers/media/platform/verisilicon/hantro_mpeg2.c
> +++ b/drivers/media/platform/verisilicon/hantro_mpeg2.c
> @@ -37,25 +37,10 @@ void hantro_mpeg2_dec_copy_qtable(u8 *qtable,
>
> int hantro_mpeg2_dec_init(struct hantro_ctx *ctx)
> {
> - struct hantro_dev *vpu = ctx->dev;
> -
> - ctx->mpeg2_dec.qtable.size = ARRAY_SIZE(zigzag) * 4;
> - ctx->mpeg2_dec.qtable.cpu =
> - dma_alloc_coherent(vpu->dev,
> - ctx->mpeg2_dec.qtable.size,
> - &ctx->mpeg2_dec.qtable.dma,
> - GFP_KERNEL);
> - if (!ctx->mpeg2_dec.qtable.cpu)
> - return -ENOMEM;
> - return 0;
> + return hantro_allocate_aux_buf(ctx, &ctx->mpeg2_dec.qtable, ARRAY_SIZE(zigzag) * 4);
> }
>
> void hantro_mpeg2_dec_exit(struct hantro_ctx *ctx)
> {
> - struct hantro_dev *vpu = ctx->dev;
> -
> - dma_free_coherent(vpu->dev,
> - ctx->mpeg2_dec.qtable.size,
> - ctx->mpeg2_dec.qtable.cpu,
> - ctx->mpeg2_dec.qtable.dma);
> + hantro_free_aux_buf(ctx, &ctx->mpeg2_dec.qtable);
> }

Attachment: signature.asc
Description: This is a digitally signed message part