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

Nicolas Dufresne nicolas.dufresne at collabora.com
Mon Nov 23 11:15:06 PST 2026


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 at collabora.com>
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
> ---
> 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);
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20261123/3e89c672/attachment-0001.sig>


More information about the Linux-rockchip mailing list