diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2015-06-24 19:55:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-24 20:49:40 -0400 |
commit | 3693a84d3b8b2fd4db1f1b22f33793eb84a66420 (patch) | |
tree | 4f8e5305fda1c5e15daaa01bec5e4935bd1a371c /arch | |
parent | f51c0eaee39e306458d2bf8a30e010615fa451cc (diff) |
xtensa: use for_each_sg()
This replaces the plain loop over the sglist array with for_each_sg()
macro which consists of sg_next() function calls. Since xtensa doesn't
select ARCH_HAS_SG_CHAIN, it is not necessary to use for_each_sg() in
order to loop over each sg element. But this can help find problems
with drivers that do not properly initialize their sg tables when
CONFIG_DEBUG_SG is enabled.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/xtensa/include/asm/dma-mapping.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/arch/xtensa/include/asm/dma-mapping.h b/arch/xtensa/include/asm/dma-mapping.h index ba78ccf651e7..1f5f6dc09736 100644 --- a/arch/xtensa/include/asm/dma-mapping.h +++ b/arch/xtensa/include/asm/dma-mapping.h | |||
@@ -52,14 +52,15 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | |||
52 | } | 52 | } |
53 | 53 | ||
54 | static inline int | 54 | static inline int |
55 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | 55 | dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, |
56 | enum dma_data_direction direction) | 56 | enum dma_data_direction direction) |
57 | { | 57 | { |
58 | int i; | 58 | int i; |
59 | struct scatterlist *sg; | ||
59 | 60 | ||
60 | BUG_ON(direction == DMA_NONE); | 61 | BUG_ON(direction == DMA_NONE); |
61 | 62 | ||
62 | for (i = 0; i < nents; i++, sg++ ) { | 63 | for_each_sg(sglist, sg, nents, i) { |
63 | BUG_ON(!sg_page(sg)); | 64 | BUG_ON(!sg_page(sg)); |
64 | 65 | ||
65 | sg->dma_address = sg_phys(sg); | 66 | sg->dma_address = sg_phys(sg); |
@@ -124,20 +125,24 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, | |||
124 | consistent_sync((void *)bus_to_virt(dma_handle)+offset,size,direction); | 125 | consistent_sync((void *)bus_to_virt(dma_handle)+offset,size,direction); |
125 | } | 126 | } |
126 | static inline void | 127 | static inline void |
127 | dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, | 128 | dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist, int nelems, |
128 | enum dma_data_direction dir) | 129 | enum dma_data_direction dir) |
129 | { | 130 | { |
130 | int i; | 131 | int i; |
131 | for (i = 0; i < nelems; i++, sg++) | 132 | struct scatterlist *sg; |
133 | |||
134 | for_each_sg(sglist, sg, nelems, i) | ||
132 | consistent_sync(sg_virt(sg), sg->length, dir); | 135 | consistent_sync(sg_virt(sg), sg->length, dir); |
133 | } | 136 | } |
134 | 137 | ||
135 | static inline void | 138 | static inline void |
136 | dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, | 139 | dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, |
137 | enum dma_data_direction dir) | 140 | int nelems, enum dma_data_direction dir) |
138 | { | 141 | { |
139 | int i; | 142 | int i; |
140 | for (i = 0; i < nelems; i++, sg++) | 143 | struct scatterlist *sg; |
144 | |||
145 | for_each_sg(sglist, sg, nelems, i) | ||
141 | consistent_sync(sg_virt(sg), sg->length, dir); | 146 | consistent_sync(sg_virt(sg), sg->length, dir); |
142 | } | 147 | } |
143 | static inline int | 148 | static inline int |