From afd1a321c49a250dab97cef6f2d3c3c9b9d0174a Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 16:30:57 +0100 Subject: [ARM] Update dma_map_sg()/dma_unmap_sg() API Update the ARM DMA scatter gather APIs for the scatterlist changes. Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index aecc6c3f908..35c72bcf3d0 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -435,6 +435,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -442,14 +443,13 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - struct page *page = sg_page(sg); - unsigned int offset = sg->offset; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + struct page *page = sg_page(s); + unsigned int offset = s->offset; + unsigned int length = s->length; void *ptr = page_address(page) + offset; - sg->dma_address = - map_single(dev, ptr, length, dir); + s->dma_address = map_single(dev, ptr, length, dir); } return nents; @@ -459,6 +459,7 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -466,9 +467,9 @@ dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - dma_addr_t dma_addr = sg->dma_address; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + dma_addr_t dma_addr = s->dma_address; + unsigned int length = s->length; unmap_single(dev, dma_addr, length, dir); } @@ -502,6 +503,7 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -509,9 +511,9 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - dma_addr_t dma_addr = sg->dma_address; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + dma_addr_t dma_addr = s->dma_address; + unsigned int length = s->length; sync_single(dev, dma_addr, length, dir); } @@ -521,6 +523,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -528,9 +531,9 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - dma_addr_t dma_addr = sg->dma_address; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + dma_addr_t dma_addr = s->dma_address; + unsigned int length = s->length; sync_single(dev, dma_addr, length, dir); } -- cgit v1.2.3