Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

frv: 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 frv 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: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Akinobu Mita and committed by
Linus Torvalds
0989e1f9 3fe111fc

+10 -7
+6 -4
arch/frv/mb93090-mb00/pci-dma-nommu.c
··· 119 119 120 120 EXPORT_SYMBOL(dma_map_single); 121 121 122 - int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 122 + int dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, 123 123 enum dma_data_direction direction) 124 124 { 125 125 int i; 126 + struct scatterlist *sg; 126 127 127 - for (i=0; i<nents; i++) 128 - frv_cache_wback_inv(sg_dma_address(&sg[i]), 129 - sg_dma_address(&sg[i]) + sg_dma_len(&sg[i])); 128 + for_each_sg(sglist, sg, nents, i) { 129 + frv_cache_wback_inv(sg_dma_address(sg), 130 + sg_dma_address(sg) + sg_dma_len(sg)); 131 + } 130 132 131 133 BUG_ON(direction == DMA_NONE); 132 134
+4 -3
arch/frv/mb93090-mb00/pci-dma.c
··· 50 50 51 51 EXPORT_SYMBOL(dma_map_single); 52 52 53 - int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 53 + int dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, 54 54 enum dma_data_direction direction) 55 55 { 56 56 unsigned long dampr2; 57 57 void *vaddr; 58 58 int i; 59 + struct scatterlist *sg; 59 60 60 61 BUG_ON(direction == DMA_NONE); 61 62 62 63 dampr2 = __get_DAMPR(2); 63 64 64 - for (i = 0; i < nents; i++) { 65 - vaddr = kmap_atomic_primary(sg_page(&sg[i])); 65 + for_each_sg(sglist, sg, nents, i) { 66 + vaddr = kmap_atomic_primary(sg_page(sg)); 66 67 67 68 frv_dcache_writeback((unsigned long) vaddr, 68 69 (unsigned long) vaddr + PAGE_SIZE);