]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dmaengine: altera-msgdma: use sg_nents_for_dma() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 8 Jan 2026 10:50:13 +0000 (11:50 +0100)
committerVinod Koul <vkoul@kernel.org>
Fri, 9 Jan 2026 03:06:00 +0000 (08:36 +0530)
Instead of open coded variant let's use recently introduced helper.

Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260108105619.3513561-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/altera-msgdma.c

index a203fdd84950ef8393a7b4daa26398f2dbfc7a52..50534a6045a0ff8969f2582729c6ce97dcb86abe 100644 (file)
@@ -396,13 +396,11 @@ msgdma_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl,
        void *desc = NULL;
        size_t len, avail;
        dma_addr_t dma_dst, dma_src;
-       u32 desc_cnt = 0, i;
-       struct scatterlist *sg;
+       u32 desc_cnt;
        u32 stride;
        unsigned long irqflags;
 
-       for_each_sg(sgl, sg, sg_len, i)
-               desc_cnt += DIV_ROUND_UP(sg_dma_len(sg), MSGDMA_MAX_TRANS_LEN);
+       desc_cnt = sg_nents_for_dma(sgl, sg_len, MSGDMA_MAX_TRANS_LEN);
 
        spin_lock_irqsave(&mdev->lock, irqflags);
        if (desc_cnt > mdev->desc_free_cnt) {