Skip to content

Commit 107fdf0

Browse files
andy-shevvinodkoul
authored andcommitted
dmaengine: qcom: bam_dma: 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-11-andriy.shevchenko@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 425f871 commit 107fdf0

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

drivers/dma/qcom/bam_dma.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -653,22 +653,17 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
653653
struct scatterlist *sg;
654654
u32 i;
655655
struct bam_desc_hw *desc;
656-
unsigned int num_alloc = 0;
657-
656+
unsigned int num_alloc;
658657

659658
if (!is_slave_direction(direction)) {
660659
dev_err(bdev->dev, "invalid dma direction\n");
661660
return NULL;
662661
}
663662

664-
/* calculate number of required entries */
665-
for_each_sg(sgl, sg, sg_len, i)
666-
num_alloc += DIV_ROUND_UP(sg_dma_len(sg), BAM_FIFO_SIZE);
667-
668663
/* allocate enough room to accommodate the number of entries */
664+
num_alloc = sg_nents_for_dma(sgl, sg_len, BAM_FIFO_SIZE);
669665
async_desc = kzalloc(struct_size(async_desc, desc, num_alloc),
670666
GFP_NOWAIT);
671-
672667
if (!async_desc)
673668
return NULL;
674669

0 commit comments

Comments
 (0)