Nicholas Flintham | 1e3d311 | 2013-04-10 10:48:38 +0100 | [diff] [blame^] | 1 | #ifndef _DMA_ATTR_H |
| 2 | #define _DMA_ATTR_H |
| 3 | |
| 4 | #include <linux/bitmap.h> |
| 5 | #include <linux/bitops.h> |
| 6 | #include <linux/bug.h> |
| 7 | |
| 8 | enum dma_attr { |
| 9 | DMA_ATTR_WRITE_BARRIER, |
| 10 | DMA_ATTR_WEAK_ORDERING, |
| 11 | DMA_ATTR_WRITE_COMBINE, |
| 12 | DMA_ATTR_NON_CONSISTENT, |
| 13 | DMA_ATTR_MAX, |
| 14 | }; |
| 15 | |
| 16 | #define __DMA_ATTRS_LONGS BITS_TO_LONGS(DMA_ATTR_MAX) |
| 17 | |
| 18 | struct dma_attrs { |
| 19 | unsigned long flags[__DMA_ATTRS_LONGS]; |
| 20 | }; |
| 21 | |
| 22 | #define DEFINE_DMA_ATTRS(x) \ |
| 23 | struct dma_attrs x = { \ |
| 24 | .flags = { [0 ... __DMA_ATTRS_LONGS-1] = 0 }, \ |
| 25 | } |
| 26 | |
| 27 | static inline void init_dma_attrs(struct dma_attrs *attrs) |
| 28 | { |
| 29 | bitmap_zero(attrs->flags, __DMA_ATTRS_LONGS); |
| 30 | } |
| 31 | |
| 32 | #ifdef CONFIG_HAVE_DMA_ATTRS |
| 33 | static inline void dma_set_attr(enum dma_attr attr, struct dma_attrs *attrs) |
| 34 | { |
| 35 | if (attrs == NULL) |
| 36 | return; |
| 37 | BUG_ON(attr >= DMA_ATTR_MAX); |
| 38 | __set_bit(attr, attrs->flags); |
| 39 | } |
| 40 | |
| 41 | static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs) |
| 42 | { |
| 43 | if (attrs == NULL) |
| 44 | return 0; |
| 45 | BUG_ON(attr >= DMA_ATTR_MAX); |
| 46 | return test_bit(attr, attrs->flags); |
| 47 | } |
| 48 | #else |
| 49 | static inline void dma_set_attr(enum dma_attr attr, struct dma_attrs *attrs) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs) |
| 54 | { |
| 55 | return 0; |
| 56 | } |
| 57 | #endif |
| 58 | #endif |