On Thu, Mar 26, 2026 at 07:59:43PM -0700, Rosen Penev wrote:
> Simplifies allocations by using a flexible array member in this struct.
>
> Remove hsu_dma_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 hsu_dma and devm_kzalloc.
We refer to the functions in the comments and commit messages as func().
Please, update this patch accordingly.
...
> static void hsu_dma_desc_free(struct virt_dma_desc *vdesc)
> {
> struct hsu_dma_desc *desc = to_hsu_dma_desc(vdesc);
>
> - kfree(desc->sg);
> kfree(desc);
It can be collapsed to a single line, but for the sake of clarity the above is
okay.
> }
...
> - desc = hsu_dma_alloc_desc(sg_len);
> + desc = kzalloc_flex(*desc, sg, sg_len, GFP_NOWAIT);
> if (!desc)
> return NULL;
>
> + desc->nents = sg_len;
> +
> - desc->nents = sg_len;
> desc->direction = direction;
> /* desc->active = 0 by kzalloc */
> desc->status = DMA_IN_PROGRESS;
This nents move makes disruption is the field assignment block.
Please, move them all up.
...
> void __iomem *addr = chip->regs + chip->offset;
> unsigned short i;
> int ret;
> + unsigned short nr_channels;
Preserve reversed xmas tree order.
...
> - hsu = devm_kzalloc(chip->dev, sizeof(*hsu), GFP_KERNEL);
> + /* Calculate nr_channels from the IO space length */
> + nr_channels = (chip->length - chip->offset) / HSU_DMA_CHAN_LENGTH;
> + hsu = devm_kzalloc(chip->dev, struct_size(hsu, chan, nr_channels),
> GFP_KERNEL);
> if (!hsu)
> return -ENOMEM;
>
> + hsu->nr_channels = nr_channels;
+ blank line.
> chip->hsu = hsu;
--
With Best Regards,
Andy Shevchenko