On Fri, Mar 20, 2026 at 08:49:31PM -0700, Rosen Penev wrote:
> Simplifies allocations by using a flexible array member in this struct.
>
> Remove idma64_alloc_desc. It now offers no readability advantages in
> this single usage.
>
> Add __counted_by to get extra runtime analysis.
>
> Apply the exact same treatment to struct idma64_dma and devm_kzalloc.
>
> Signed-off-by: Rosen Penev <[email protected]>
> ---
>  v2: allocate with GFP_NOWAIT. Was mistakenly removed.
>  drivers/dma/idma64.c | 30 ++++--------------------------
>  drivers/dma/idma64.h |  4 ++--
>  2 files changed, 6 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/dma/idma64.c b/drivers/dma/idma64.c
> index 5fcd1befc92d..d914f50ec309 100644
> --- a/drivers/dma/idma64.c
> +++ b/drivers/dma/idma64.c
> @@ -192,23 +192,6 @@ static irqreturn_t idma64_irq(int irq, void *dev)
>
>  /* ---------------------------------------------------------------------- */
>
> -static struct idma64_desc *idma64_alloc_desc(unsigned int ndesc)
> -{
> -     struct idma64_desc *desc;
> -
> -     desc = kzalloc_obj(*desc, GFP_NOWAIT);
> -     if (!desc)
> -             return NULL;
> -
> -     desc->hw = kzalloc_objs(*desc->hw, ndesc, GFP_NOWAIT);
> -     if (!desc->hw) {
> -             kfree(desc);
> -             return NULL;
> -     }
> -
> -     return desc;
> -}
> -
>  static void idma64_desc_free(struct idma64_chan *idma64c,
>               struct idma64_desc *desc)
>  {
> @@ -223,7 +206,6 @@ static void idma64_desc_free(struct idma64_chan *idma64c,
>               } while (i);
>       }
>
> -     kfree(desc->hw);
>       kfree(desc);
>  }
>
> @@ -307,10 +289,12 @@ static struct dma_async_tx_descriptor 
> *idma64_prep_slave_sg(
>       struct scatterlist *sg;
>       unsigned int i;
>
> -     desc = idma64_alloc_desc(sg_len);
> +     desc = kzalloc_flex(*desc, hw, sg_len, GFP_NOWAIT);
>       if (!desc)
>               return NULL;
>
> +     desc->ndesc = sg_len;
> +

This patch is okay, but suggest use sg_nents_for_dma() later

Reviewed-by: Frank Li <[email protected]>

>

Reply via email to