Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dmaengine.h
Go to the documentation of this file.
1 /*
2  * The contents of this file are private to DMA engine drivers, and is not
3  * part of the API to be used by DMA engine users.
4  */
5 #ifndef DMAENGINE_H
6 #define DMAENGINE_H
7 
8 #include <linux/bug.h>
9 #include <linux/dmaengine.h>
10 
15 static inline void dma_cookie_init(struct dma_chan *chan)
16 {
17  chan->cookie = DMA_MIN_COOKIE;
19 }
20 
28 static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descriptor *tx)
29 {
30  struct dma_chan *chan = tx->chan;
32 
33  cookie = chan->cookie + 1;
34  if (cookie < DMA_MIN_COOKIE)
35  cookie = DMA_MIN_COOKIE;
36  tx->cookie = chan->cookie = cookie;
37 
38  return cookie;
39 }
40 
51 static inline void dma_cookie_complete(struct dma_async_tx_descriptor *tx)
52 {
54  tx->chan->completed_cookie = tx->cookie;
55  tx->cookie = 0;
56 }
57 
67 static inline enum dma_status dma_cookie_status(struct dma_chan *chan,
68  dma_cookie_t cookie, struct dma_tx_state *state)
69 {
71 
72  used = chan->cookie;
73  complete = chan->completed_cookie;
74  barrier();
75  if (state) {
76  state->last = complete;
77  state->used = used;
78  state->residue = 0;
79  }
80  return dma_async_is_complete(cookie, complete, used);
81 }
82 
83 static inline void dma_set_residue(struct dma_tx_state *state, u32 residue)
84 {
85  if (state)
86  state->residue = residue;
87 }
88 
89 #endif