aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2005-09-29 17:43:32 -0400
committerTony Luck <tony.luck@intel.com>2005-09-29 17:43:32 -0400
commit8270f3f1a605c83b3aa516c1eaed209fe0884e84 (patch)
treedbe49f6263658cd9b7ace81fed257009140c0b9e /lib
parent6c654b5fdf093cd05f35f7c9c2a00182fa5636dc (diff)
[PATCH] swiotlb: cleanup some code duplication cruft
The implementations of swiotlb_sync_single_for_{cpu,device} are identical. Likewise for swiotlb_syng_sg_for_{cpu,device}. This patch move the guts of those functions to two new inline functions, and calls the appropriate one from the bodies of those functions. Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/swiotlb.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 875b0c16250c..9719a14649e7 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -594,9 +594,9 @@ swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
594 * address back to the card, you must first perform a 594 * address back to the card, you must first perform a
595 * swiotlb_dma_sync_for_device, and then the device again owns the buffer 595 * swiotlb_dma_sync_for_device, and then the device again owns the buffer
596 */ 596 */
597void 597static inline void
598swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr, 598swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
599 size_t size, int dir) 599 size_t size, int dir)
600{ 600{
601 char *dma_addr = phys_to_virt(dev_addr); 601 char *dma_addr = phys_to_virt(dev_addr);
602 602
@@ -609,17 +609,17 @@ swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
609} 609}
610 610
611void 611void
612swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
613 size_t size, int dir)
614{
615 swiotlb_sync_single(hwdev, dev_addr, size, dir);
616}
617
618void
612swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr, 619swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
613 size_t size, int dir) 620 size_t size, int dir)
614{ 621{
615 char *dma_addr = phys_to_virt(dev_addr); 622 swiotlb_sync_single(hwdev, dev_addr, size, dir);
616
617 if (dir == DMA_NONE)
618 BUG();
619 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
620 sync_single(hwdev, dma_addr, size, dir);
621 else if (dir == DMA_FROM_DEVICE)
622 mark_clean(dma_addr, size);
623} 623}
624 624
625/* 625/*
@@ -696,9 +696,9 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
696 * The same as swiotlb_sync_single_* but for a scatter-gather list, same rules 696 * The same as swiotlb_sync_single_* but for a scatter-gather list, same rules
697 * and usage. 697 * and usage.
698 */ 698 */
699void 699static inline void
700swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, 700swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg,
701 int nelems, int dir) 701 int nelems, int dir)
702{ 702{
703 int i; 703 int i;
704 704
@@ -712,18 +712,17 @@ swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
712} 712}
713 713
714void 714void
715swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
716 int nelems, int dir)
717{
718 swiotlb_sync_sg(hwdev, sg, nelems, dir);
719}
720
721void
715swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, 722swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
716 int nelems, int dir) 723 int nelems, int dir)
717{ 724{
718 int i; 725 swiotlb_sync_sg(hwdev, sg, nelems, dir);
719
720 if (dir == DMA_NONE)
721 BUG();
722
723 for (i = 0; i < nelems; i++, sg++)
724 if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
725 sync_single(hwdev, (void *) sg->dma_address,
726 sg->dma_length, dir);
727} 726}
728 727
729int 728int