diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2009-08-09 22:53:13 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-10 03:34:59 -0400 |
commit | 02f7a18935eef0e56d9180fc3c35da6aad1ff3bb (patch) | |
tree | 26435d2e792b4e61f55e41c8e91f106b3e030cd8 /arch/sparc/include/asm/dma-mapping.h | |
parent | bc0a14f154069cc4e42ea903c2c2b9984a94e4b7 (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/include/asm/dma-mapping.h')
-rw-r--r-- | arch/sparc/include/asm/dma-mapping.h | 107 |
1 files changed, 13 insertions, 94 deletions
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 | ||
16 | extern const struct dma_map_ops *dma_ops; | 17 | extern struct dma_map_ops *dma_ops; |
17 | 18 | ||
18 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 19 | static 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 | |||
24 | static 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 | |||
30 | static 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 | ||
39 | static 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 | |||
46 | static 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 | ||
53 | static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, | 26 | static 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 | |||
60 | static 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 | |||
66 | static 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 | |||
72 | static 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 | |||
79 | static 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 | |||
89 | static 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 | ||
96 | static 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 | ||
104 | static inline void dma_sync_single_range_for_cpu(struct device *dev, | 34 | static 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 | ||
113 | static 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 | |||
123 | static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | 42 | static 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); |