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

index 6be54fddcee18f9be6b5fee9f55c4bbd9a99ca56..490edad20ae6af1957fc7ba495091489b3178fd7 100644 (file)
@@ -390,16 +390,15 @@ static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan,
        }
 
        /* iterate through sgs and compute allocation size of structures */
-       for_each_sg(sgl, sg, sg_len, i) {
-               if (achan->slave.device_fc) {
+       if (achan->slave.device_fc) {
+               for_each_sg(sgl, sg, sg_len, i) {
                        box_count += DIV_ROUND_UP(sg_dma_len(sg) / burst,
                                                  ADM_MAX_ROWS);
                        if (sg_dma_len(sg) % burst)
                                single_count++;
-               } else {
-                       single_count += DIV_ROUND_UP(sg_dma_len(sg),
-                                                    ADM_MAX_XFER);
                }
+       } else {
+               single_count = sg_nents_for_dma(sgl, sg_len, ADM_MAX_XFER);
        }
 
        async_desc = kzalloc(sizeof(*async_desc), GFP_NOWAIT);