dmaengine: lgm: use sg_nents_for_dma() helper

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-8-andriy.shevchenko@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
Andy Shevchenko 2026-01-08 11:50:18 +01:00 committed by Vinod Koul
parent 3fc49d21f3
commit f9b0274f53

View file

@ -1164,8 +1164,8 @@ ldma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
struct dw2_desc *hw_ds;
struct dw2_desc_sw *ds;
struct scatterlist *sg;
int num = sglen, i;
dma_addr_t addr;
int num, i;
if (!sgl)
return NULL;
@ -1173,12 +1173,7 @@ ldma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
if (d->ver > DMA_VER22)
return ldma_chan_desc_cfg(chan, sgl->dma_address, sglen);
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 = dma_alloc_desc_resource(num, c);
if (!ds)
return NULL;