aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dma-mapping.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/dma-mapping.h')
-rw-r--r--include/linux/dma-mapping.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 3a8d0a2af607..fd4aee29ad10 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -97,6 +97,30 @@ static inline int dma_set_coherent_mask(struct device *dev, u64 mask)
97} 97}
98#endif 98#endif
99 99
100/*
101 * Set both the DMA mask and the coherent DMA mask to the same thing.
102 * Note that we don't check the return value from dma_set_coherent_mask()
103 * as the DMA API guarantees that the coherent DMA mask can be set to
104 * the same or smaller than the streaming DMA mask.
105 */
106static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
107{
108 int rc = dma_set_mask(dev, mask);
109 if (rc == 0)
110 dma_set_coherent_mask(dev, mask);
111 return rc;
112}
113
114/*
115 * Similar to the above, except it deals with the case where the device
116 * does not have dev->dma_mask appropriately setup.
117 */
118static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)
119{
120 dev->dma_mask = &dev->coherent_dma_mask;
121 return dma_set_mask_and_coherent(dev, mask);
122}
123
100extern u64 dma_get_required_mask(struct device *dev); 124extern u64 dma_get_required_mask(struct device *dev);
101 125
102static inline unsigned int dma_get_max_seg_size(struct device *dev) 126static inline unsigned int dma_get_max_seg_size(struct device *dev)
@@ -129,6 +153,13 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
129 return -EIO; 153 return -EIO;
130} 154}
131 155
156#ifndef dma_max_pfn
157static inline unsigned long dma_max_pfn(struct device *dev)
158{
159 return *dev->dma_mask >> PAGE_SHIFT;
160}
161#endif
162
132static inline void *dma_zalloc_coherent(struct device *dev, size_t size, 163static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
133 dma_addr_t *dma_handle, gfp_t flag) 164 dma_addr_t *dma_handle, gfp_t flag)
134{ 165{