diff options
-rw-r--r-- | Documentation/DMA-API.txt | 7 | ||||
-rw-r--r-- | include/linux/dma-mapping.h | 10 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index fe2326906610..66bd97a95f10 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt | |||
@@ -50,6 +50,13 @@ specify the GFP_ flags (see kmalloc) for the allocation (the | |||
50 | implementation may choose to ignore flags that affect the location of | 50 | implementation may choose to ignore flags that affect the location of |
51 | the returned memory, like GFP_DMA). | 51 | the returned memory, like GFP_DMA). |
52 | 52 | ||
53 | void * | ||
54 | dma_zalloc_coherent(struct device *dev, size_t size, | ||
55 | dma_addr_t *dma_handle, gfp_t flag) | ||
56 | |||
57 | Wraps dma_alloc_coherent() and also zeroes the returned memory if the | ||
58 | allocation attempt succeeded. | ||
59 | |||
53 | void | 60 | void |
54 | dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, | 61 | dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, |
55 | dma_addr_t dma_handle) | 62 | dma_addr_t dma_handle) |
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 347fdc32177a..be86ae13893f 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef _LINUX_DMA_MAPPING_H | 1 | #ifndef _LINUX_DMA_MAPPING_H |
2 | #define _LINUX_DMA_MAPPING_H | 2 | #define _LINUX_DMA_MAPPING_H |
3 | 3 | ||
4 | #include <linux/string.h> | ||
4 | #include <linux/device.h> | 5 | #include <linux/device.h> |
5 | #include <linux/err.h> | 6 | #include <linux/err.h> |
6 | #include <linux/dma-attrs.h> | 7 | #include <linux/dma-attrs.h> |
@@ -117,6 +118,15 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) | |||
117 | return -EIO; | 118 | return -EIO; |
118 | } | 119 | } |
119 | 120 | ||
121 | static inline void *dma_zalloc_coherent(struct device *dev, size_t size, | ||
122 | dma_addr_t *dma_handle, gfp_t flag) | ||
123 | { | ||
124 | void *ret = dma_alloc_coherent(dev, size, dma_handle, flag); | ||
125 | if (ret) | ||
126 | memset(ret, 0, size); | ||
127 | return ret; | ||
128 | } | ||
129 | |||
120 | #ifdef CONFIG_HAS_DMA | 130 | #ifdef CONFIG_HAS_DMA |
121 | static inline int dma_get_cache_alignment(void) | 131 | static inline int dma_get_cache_alignment(void) |
122 | { | 132 | { |