diff mbox

[v1,03/10] dmaengine: coh901318: use sg_nents_for_dma() helper

Message ID 20161021173535.100245-3-andriy.shevchenko@linux.intel.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Andy Shevchenko Oct. 21, 2016, 5:35 p.m. UTC
Instead of open coded variant let's use recently introduced helper.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/dma/coh901318.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
diff mbox

Patch

diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index 74794c9..d64b850 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -2279,10 +2279,7 @@  coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
 	struct coh901318_lli *lli;
 	struct coh901318_desc *cohd;
 	const struct coh901318_params *params;
-	struct scatterlist *sg;
-	int len = 0;
-	int size;
-	int i;
+	int len;
 	u32 ctrl_chained = cohc_chan_param(cohc)->ctrl_lli_chained;
 	u32 ctrl = cohc_chan_param(cohc)->ctrl_lli;
 	u32 ctrl_last = cohc_chan_param(cohc)->ctrl_lli_last;
@@ -2338,21 +2335,7 @@  coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
 	 * MAX_DMA_PACKET_SIZE. Calculate to total number of
 	 * dma elemts required to send the entire sg list
 	 */
-	for_each_sg(sgl, sg, sg_len, i) {
-		unsigned int factor;
-		size = sg_dma_len(sg);
-
-		if (size <= MAX_DMA_PACKET_SIZE) {
-			len++;
-			continue;
-		}
-
-		factor = size >> MAX_DMA_PACKET_SIZE_SHIFT;
-		if ((factor << MAX_DMA_PACKET_SIZE_SHIFT) < size)
-			factor++;
-
-		len += factor;
-	}
+	len = sg_nents_for_dma(sgl, sg_len, MAX_DMA_PACKET_SIZE);
 
 	pr_debug("Allocate %d lli:s for this transfer\n", len);
 	lli = coh901318_lli_alloc(&cohc->base->pool, len);