]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dmaengine: k3dma: use sg_nents_for_dma() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 8 Jan 2026 10:50:17 +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-7-andriy.shevchenko@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/k3dma.c

index 0f9cd7815f880ee29265ad4bb773d992a81dcce3..63677c0b6f187e51a35f6621cbf96c98cbd10893 100644 (file)
@@ -536,19 +536,14 @@ static struct dma_async_tx_descriptor *k3_dma_prep_slave_sg(
        size_t len, avail, total = 0;
        struct scatterlist *sg;
        dma_addr_t addr, src = 0, dst = 0;
-       int num = sglen, i;
+       int num, i;
 
        if (sgl == NULL)
                return NULL;
 
        c->cyclic = 0;
 
-       for_each_sg(sgl, sg, sglen, i) {
-               avail = sg_dma_len(sg);
-               if (avail > DMA_MAX_SIZE)
-                       num += DIV_ROUND_UP(avail, DMA_MAX_SIZE) - 1;
-       }
-
+       num = sg_nents_for_dma(sgl, sglen, DMA_MAX_SIZE);
        ds = k3_dma_alloc_desc_resource(num, chan);
        if (!ds)
                return NULL;