Skip to content

Commit d778566

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

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/dma/sa11x0-dma.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
526526
struct sa11x0_dma_chan *c = to_sa11x0_dma_chan(chan);
527527
struct sa11x0_dma_desc *txd;
528528
struct scatterlist *sgent;
529-
unsigned i, j = sglen;
529+
unsigned int i, j;
530530
size_t size = 0;
531531

532532
/* SA11x0 channels can only operate in their native direction */
@@ -542,17 +542,15 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
542542

543543
for_each_sg(sg, sgent, sglen, i) {
544544
dma_addr_t addr = sg_dma_address(sgent);
545-
unsigned int len = sg_dma_len(sgent);
546545

547-
if (len > DMA_MAX_SIZE)
548-
j += DIV_ROUND_UP(len, DMA_MAX_SIZE & ~DMA_ALIGN) - 1;
549546
if (addr & DMA_ALIGN) {
550547
dev_dbg(chan->device->dev, "vchan %p: bad buffer alignment: %pad\n",
551548
&c->vc, &addr);
552549
return NULL;
553550
}
554551
}
555552

553+
j = sg_nents_for_dma(sg, sglen, DMA_MAX_SIZE & ~DMA_ALIGN);
556554
txd = kzalloc(struct_size(txd, sg, j), GFP_ATOMIC);
557555
if (!txd) {
558556
dev_dbg(chan->device->dev, "vchan %p: kzalloc failed\n", &c->vc);

0 commit comments

Comments
 (0)