diff mbox

[v1,04/10] dmaengine: imx-dma: use sg_nents_for_dma() helper

Message ID 20161021173535.100245-4-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 <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/imx-dma.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Vinod Koul Nov. 14, 2016, 3:19 a.m. UTC | #1
On Fri, Oct 21, 2016 at 08:35:29PM +0300, Andy Shevchenko wrote:
> Instead of open coded variant let's use recently introduced helper.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/dma/imx-dma.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
> index ab0fb80..a3cb4fe 100644
> --- a/drivers/dma/imx-dma.c
> +++ b/drivers/dma/imx-dma.c
> @@ -813,8 +813,6 @@ static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
>  		unsigned long flags, void *context)
>  {
>  	struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
> -	struct scatterlist *sg;
> -	int i, dma_length = 0;
>  	struct imxdma_desc *desc;
>  
>  	if (list_empty(&imxdmac->ld_free) ||
> @@ -823,10 +821,6 @@ static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
>  
>  	desc = list_first_entry(&imxdmac->ld_free, struct imxdma_desc, node);
>  
> -	for_each_sg(sgl, sg, sg_len, i) {
> -		dma_length += sg_dma_len(sg);
> -	}
> -
>  	switch (imxdmac->word_size) {
>  	case DMA_SLAVE_BUSWIDTH_4_BYTES:
>  		if (sg_dma_len(sgl) & 3 || sgl->dma_address & 3)
> @@ -845,7 +839,7 @@ static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
>  	desc->type = IMXDMA_DESC_SLAVE_SG;
>  	desc->sg = sgl;
>  	desc->sgcount = sg_len;
> -	desc->len = dma_length;
> +	desc->len = sg_nents_for_dma(sgl, sg_len, SIZE_MAX);

Okay now am convinced this doesn't sound right... Here would would rturn
entries and not length which is required..
diff mbox

Patch

diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index ab0fb80..a3cb4fe 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -813,8 +813,6 @@  static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
 		unsigned long flags, void *context)
 {
 	struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
-	struct scatterlist *sg;
-	int i, dma_length = 0;
 	struct imxdma_desc *desc;
 
 	if (list_empty(&imxdmac->ld_free) ||
@@ -823,10 +821,6 @@  static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
 
 	desc = list_first_entry(&imxdmac->ld_free, struct imxdma_desc, node);
 
-	for_each_sg(sgl, sg, sg_len, i) {
-		dma_length += sg_dma_len(sg);
-	}
-
 	switch (imxdmac->word_size) {
 	case DMA_SLAVE_BUSWIDTH_4_BYTES:
 		if (sg_dma_len(sgl) & 3 || sgl->dma_address & 3)
@@ -845,7 +839,7 @@  static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
 	desc->type = IMXDMA_DESC_SLAVE_SG;
 	desc->sg = sgl;
 	desc->sgcount = sg_len;
-	desc->len = dma_length;
+	desc->len = sg_nents_for_dma(sgl, sg_len, SIZE_MAX);
 	desc->direction = direction;
 	if (direction == DMA_DEV_TO_MEM) {
 		desc->src = imxdmac->per_address;