blob: e164e70b927bf186f90c1bf44b380b05c109c656 [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001#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
8enum 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
18struct 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
27static 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
33static 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
41static 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
49static inline void dma_set_attr(enum dma_attr attr, struct dma_attrs *attrs)
50{
51}
52
53static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs)
54{
55 return 0;
56}
57#endif
58#endif