kvm tools, setup: Create private directory
[linux-2.6/next.git] / arch / mips / include / asm / dma-mapping.h
blob7aa37ddfca4ba59b25603183a1d5bca23099fa9c
1 #ifndef _ASM_DMA_MAPPING_H
2 #define _ASM_DMA_MAPPING_H
4 #include <asm/scatterlist.h>
5 #include <asm/cache.h>
6 #include <asm-generic/dma-coherent.h>
8 #ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
9 #include <dma-coherence.h>
10 #endif
12 extern struct dma_map_ops *mips_dma_map_ops;
14 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
16 if (dev && dev->archdata.dma_ops)
17 return dev->archdata.dma_ops;
18 else
19 return mips_dma_map_ops;
22 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
24 if (!dev->dma_mask)
25 return 0;
27 return addr + size <= *dev->dma_mask;
30 static inline void dma_mark_clean(void *addr, size_t size) {}
32 #include <asm-generic/dma-mapping-common.h>
34 static inline int dma_supported(struct device *dev, u64 mask)
36 struct dma_map_ops *ops = get_dma_ops(dev);
37 return ops->dma_supported(dev, mask);
40 static inline int dma_mapping_error(struct device *dev, u64 mask)
42 struct dma_map_ops *ops = get_dma_ops(dev);
43 return ops->mapping_error(dev, mask);
46 static inline int
47 dma_set_mask(struct device *dev, u64 mask)
49 if(!dev->dma_mask || !dma_supported(dev, mask))
50 return -EIO;
52 *dev->dma_mask = mask;
54 return 0;
57 extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
58 enum dma_data_direction direction);
60 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
61 dma_addr_t *dma_handle, gfp_t gfp)
63 void *ret;
64 struct dma_map_ops *ops = get_dma_ops(dev);
66 ret = ops->alloc_coherent(dev, size, dma_handle, gfp);
68 debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
70 return ret;
73 static inline void dma_free_coherent(struct device *dev, size_t size,
74 void *vaddr, dma_addr_t dma_handle)
76 struct dma_map_ops *ops = get_dma_ops(dev);
78 ops->free_coherent(dev, size, vaddr, dma_handle);
80 debug_dma_free_coherent(dev, size, vaddr, dma_handle);
84 void *dma_alloc_noncoherent(struct device *dev, size_t size,
85 dma_addr_t *dma_handle, gfp_t flag);
87 void dma_free_noncoherent(struct device *dev, size_t size,
88 void *vaddr, dma_addr_t dma_handle);
90 #endif /* _ASM_DMA_MAPPING_H */