aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-08-09 22:53:13 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-10 03:34:59 -0400
commit02f7a18935eef0e56d9180fc3c35da6aad1ff3bb (patch)
tree26435d2e792b4e61f55e41c8e91f106b3e030cd8 /arch/sparc
parentbc0a14f154069cc4e42ea903c2c2b9984a94e4b7 (diff)
sparc: Use asm-generic/dma-mapping-common.h
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Tested-by: Robert Reif <reif@earthlink.net> Acked-by: David S. Miller <davem@davemloft.net> Cc: tony.luck@intel.com Cc: fenghua.yu@intel.com LKML-Reference: <1249872797-1314-5-git-send-email-fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/include/asm/dma-mapping.h107
-rw-r--r--arch/sparc/kernel/dma.c4
-rw-r--r--arch/sparc/kernel/iommu.c4
-rw-r--r--arch/sparc/kernel/pci_sun4v.c2
5 files changed, 19 insertions, 99 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3f8b6a92eabd..5f2df99645c9 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -25,6 +25,7 @@ config SPARC
25 select ARCH_WANT_OPTIONAL_GPIOLIB 25 select ARCH_WANT_OPTIONAL_GPIOLIB
26 select RTC_CLASS 26 select RTC_CLASS
27 select RTC_DRV_M48T59 27 select RTC_DRV_M48T59
28 select HAVE_DMA_ATTRS
28 29
29config SPARC32 30config SPARC32
30 def_bool !64BIT 31 def_bool !64BIT
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 893f3ecc9750..34c92264208a 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/scatterlist.h> 4#include <linux/scatterlist.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/dma-debug.h>
6 7
7#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 8#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
8 9
@@ -13,113 +14,31 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask);
13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 14#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
14#define dma_is_consistent(d, h) (1) 15#define dma_is_consistent(d, h) (1)
15 16
16extern const struct dma_map_ops *dma_ops; 17extern struct dma_map_ops *dma_ops;
17 18
18static inline void *dma_alloc_coherent(struct device *dev, size_t size, 19static inline struct dma_map_ops *get_dma_ops(struct device *dev)
19 dma_addr_t *dma_handle, gfp_t flag)
20{
21 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
22}
23
24static inline void dma_free_coherent(struct device *dev, size_t size,
25 void *cpu_addr, dma_addr_t dma_handle)
26{
27 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
28}
29
30static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
31 size_t size,
32 enum dma_data_direction direction)
33{ 20{
34 return dma_ops->map_page(dev, virt_to_page(cpu_addr), 21 return dma_ops;
35 (unsigned long)cpu_addr & ~PAGE_MASK, size,
36 direction, NULL);
37} 22}
38 23
39static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 24#include <asm-generic/dma-mapping-common.h>
40 size_t size,
41 enum dma_data_direction direction)
42{
43 dma_ops->unmap_page(dev, dma_addr, size, direction, NULL);
44}
45
46static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
47 unsigned long offset, size_t size,
48 enum dma_data_direction direction)
49{
50 return dma_ops->map_page(dev, page, offset, size, direction, NULL);
51}
52 25
53static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, 26static inline void *dma_alloc_coherent(struct device *dev, size_t size,
54 size_t size, 27 dma_addr_t *dma_handle, gfp_t flag)
55 enum dma_data_direction direction)
56{
57 dma_ops->unmap_page(dev, dma_address, size, direction, NULL);
58}
59
60static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
61 int nents, enum dma_data_direction direction)
62{
63 return dma_ops->map_sg(dev, sg, nents, direction, NULL);
64}
65
66static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
67 int nents, enum dma_data_direction direction)
68{
69 dma_ops->unmap_sg(dev, sg, nents, direction, NULL);
70}
71
72static inline void dma_sync_single_for_cpu(struct device *dev,
73 dma_addr_t dma_handle, size_t size,
74 enum dma_data_direction direction)
75{
76 dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction);
77}
78
79static inline void dma_sync_single_for_device(struct device *dev,
80 dma_addr_t dma_handle,
81 size_t size,
82 enum dma_data_direction direction)
83{
84 if (dma_ops->sync_single_for_device)
85 dma_ops->sync_single_for_device(dev, dma_handle, size,
86 direction);
87}
88
89static inline void dma_sync_sg_for_cpu(struct device *dev,
90 struct scatterlist *sg, int nelems,
91 enum dma_data_direction direction)
92{ 28{
93 dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction); 29 struct dma_map_ops *ops = get_dma_ops(dev);
94}
95 30
96static inline void dma_sync_sg_for_device(struct device *dev, 31 return ops->alloc_coherent(dev, size, dma_handle, flag);
97 struct scatterlist *sg, int nelems,
98 enum dma_data_direction direction)
99{
100 if (dma_ops->sync_sg_for_device)
101 dma_ops->sync_sg_for_device(dev, sg, nelems, direction);
102} 32}
103 33
104static inline void dma_sync_single_range_for_cpu(struct device *dev, 34static inline void dma_free_coherent(struct device *dev, size_t size,
105 dma_addr_t dma_handle, 35 void *cpu_addr, dma_addr_t dma_handle)
106 unsigned long offset,
107 size_t size,
108 enum dma_data_direction dir)
109{ 36{
110 dma_sync_single_for_cpu(dev, dma_handle+offset, size, dir); 37 struct dma_map_ops *ops = get_dma_ops(dev);
111}
112 38
113static inline void dma_sync_single_range_for_device(struct device *dev, 39 ops->free_coherent(dev, size, cpu_addr, dma_handle);
114 dma_addr_t dma_handle,
115 unsigned long offset,
116 size_t size,
117 enum dma_data_direction dir)
118{
119 dma_sync_single_for_device(dev, dma_handle+offset, size, dir);
120} 40}
121 41
122
123static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 42static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
124{ 43{
125 return (dma_addr == DMA_ERROR_CODE); 44 return (dma_addr == DMA_ERROR_CODE);
diff --git a/arch/sparc/kernel/dma.c b/arch/sparc/kernel/dma.c
index 473a3fc7ab5b..15820a918171 100644
--- a/arch/sparc/kernel/dma.c
+++ b/arch/sparc/kernel/dma.c
@@ -165,7 +165,7 @@ static void dma32_sync_sg_for_device(struct device *dev,
165 BUG(); 165 BUG();
166} 166}
167 167
168static const struct dma_map_ops dma32_dma_ops = { 168static struct dma_map_ops dma32_dma_ops = {
169 .alloc_coherent = dma32_alloc_coherent, 169 .alloc_coherent = dma32_alloc_coherent,
170 .free_coherent = dma32_free_coherent, 170 .free_coherent = dma32_free_coherent,
171 .map_page = dma32_map_page, 171 .map_page = dma32_map_page,
@@ -178,5 +178,5 @@ static const struct dma_map_ops dma32_dma_ops = {
178 .sync_sg_for_device = dma32_sync_sg_for_device, 178 .sync_sg_for_device = dma32_sync_sg_for_device,
179}; 179};
180 180
181const struct dma_map_ops *dma_ops = &dma32_dma_ops; 181struct dma_map_ops *dma_ops = &dma32_dma_ops;
182EXPORT_SYMBOL(dma_ops); 182EXPORT_SYMBOL(dma_ops);
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index a9f0ad955186..74b289cab552 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -826,7 +826,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
826 spin_unlock_irqrestore(&iommu->lock, flags); 826 spin_unlock_irqrestore(&iommu->lock, flags);
827} 827}
828 828
829static const struct dma_map_ops sun4u_dma_ops = { 829static struct dma_map_ops sun4u_dma_ops = {
830 .alloc_coherent = dma_4u_alloc_coherent, 830 .alloc_coherent = dma_4u_alloc_coherent,
831 .free_coherent = dma_4u_free_coherent, 831 .free_coherent = dma_4u_free_coherent,
832 .map_page = dma_4u_map_page, 832 .map_page = dma_4u_map_page,
@@ -837,7 +837,7 @@ static const struct dma_map_ops sun4u_dma_ops = {
837 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu, 837 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
838}; 838};
839 839
840const struct dma_map_ops *dma_ops = &sun4u_dma_ops; 840struct dma_map_ops *dma_ops = &sun4u_dma_ops;
841EXPORT_SYMBOL(dma_ops); 841EXPORT_SYMBOL(dma_ops);
842 842
843int dma_supported(struct device *dev, u64 device_mask) 843int dma_supported(struct device *dev, u64 device_mask)
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index c4f7dce577dd..ee800f927929 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -539,7 +539,7 @@ static void dma_4v_sync_sg_for_cpu(struct device *dev,
539 /* Nothing to do... */ 539 /* Nothing to do... */
540} 540}
541 541
542static const struct dma_map_ops sun4v_dma_ops = { 542static struct dma_map_ops sun4v_dma_ops = {
543 .alloc_coherent = dma_4v_alloc_coherent, 543 .alloc_coherent = dma_4v_alloc_coherent,
544 .free_coherent = dma_4v_free_coherent, 544 .free_coherent = dma_4v_free_coherent,
545 .map_page = dma_4v_map_page, 545 .map_page = dma_4v_map_page,