diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2015-06-24 19:55:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-24 20:49:40 -0400 |
commit | 210bff6d231217c3c63e0115af7eb01603b83015 (patch) | |
tree | e012ff274418d037b0199424ec526e4934a883d7 /arch | |
parent | b519ea6d9a2f9c5d3cb90860f225564daa983bff (diff) |
parisc: 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 parisc 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: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
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/parisc/kernel/pci-dma.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c index ff834fd67478..b9402c9b3454 100644 --- a/arch/parisc/kernel/pci-dma.c +++ b/arch/parisc/kernel/pci-dma.c | |||
@@ -478,14 +478,16 @@ static void pa11_dma_unmap_single(struct device *dev, dma_addr_t dma_handle, siz | |||
478 | static int pa11_dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) | 478 | static int pa11_dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) |
479 | { | 479 | { |
480 | int i; | 480 | int i; |
481 | struct scatterlist *sg; | ||
481 | 482 | ||
482 | BUG_ON(direction == DMA_NONE); | 483 | BUG_ON(direction == DMA_NONE); |
483 | 484 | ||
484 | for (i = 0; i < nents; i++, sglist++ ) { | 485 | for_each_sg(sglist, sg, nents, i) { |
485 | unsigned long vaddr = (unsigned long)sg_virt(sglist); | 486 | unsigned long vaddr = (unsigned long)sg_virt(sg); |
486 | sg_dma_address(sglist) = (dma_addr_t) virt_to_phys(vaddr); | 487 | |
487 | sg_dma_len(sglist) = sglist->length; | 488 | sg_dma_address(sg) = (dma_addr_t) virt_to_phys(vaddr); |
488 | flush_kernel_dcache_range(vaddr, sglist->length); | 489 | sg_dma_len(sg) = sg->length; |
490 | flush_kernel_dcache_range(vaddr, sg->length); | ||
489 | } | 491 | } |
490 | return nents; | 492 | return nents; |
491 | } | 493 | } |
@@ -493,6 +495,7 @@ static int pa11_dma_map_sg(struct device *dev, struct scatterlist *sglist, int n | |||
493 | static void pa11_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) | 495 | static void pa11_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) |
494 | { | 496 | { |
495 | int i; | 497 | int i; |
498 | struct scatterlist *sg; | ||
496 | 499 | ||
497 | BUG_ON(direction == DMA_NONE); | 500 | BUG_ON(direction == DMA_NONE); |
498 | 501 | ||
@@ -501,8 +504,8 @@ static void pa11_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, in | |||
501 | 504 | ||
502 | /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ | 505 | /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ |
503 | 506 | ||
504 | for (i = 0; i < nents; i++, sglist++ ) | 507 | for_each_sg(sglist, sg, nents, i) |
505 | flush_kernel_vmap_range(sg_virt(sglist), sglist->length); | 508 | flush_kernel_vmap_range(sg_virt(sg), sg->length); |
506 | return; | 509 | return; |
507 | } | 510 | } |
508 | 511 | ||
@@ -523,21 +526,23 @@ static void pa11_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_h | |||
523 | static void pa11_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) | 526 | static void pa11_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) |
524 | { | 527 | { |
525 | int i; | 528 | int i; |
529 | struct scatterlist *sg; | ||
526 | 530 | ||
527 | /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ | 531 | /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ |
528 | 532 | ||
529 | for (i = 0; i < nents; i++, sglist++ ) | 533 | for_each_sg(sglist, sg, nents, i) |
530 | flush_kernel_vmap_range(sg_virt(sglist), sglist->length); | 534 | flush_kernel_vmap_range(sg_virt(sg), sg->length); |
531 | } | 535 | } |
532 | 536 | ||
533 | static void pa11_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) | 537 | static void pa11_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) |
534 | { | 538 | { |
535 | int i; | 539 | int i; |
540 | struct scatterlist *sg; | ||
536 | 541 | ||
537 | /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ | 542 | /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ |
538 | 543 | ||
539 | for (i = 0; i < nents; i++, sglist++ ) | 544 | for_each_sg(sglist, sg, nents, i) |
540 | flush_kernel_vmap_range(sg_virt(sglist), sglist->length); | 545 | flush_kernel_vmap_range(sg_virt(sg), sg->length); |
541 | } | 546 | } |
542 | 547 | ||
543 | struct hppa_dma_ops pcxl_dma_ops = { | 548 | struct hppa_dma_ops pcxl_dma_ops = { |