Root/
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 | |
11 | /** |
12 | * dma_cookie_init - initialize the cookies for a DMA channel |
13 | * @chan: dma channel to initialize |
14 | */ |
15 | static inline void dma_cookie_init(struct dma_chan *chan) |
16 | { |
17 | chan->cookie = DMA_MIN_COOKIE; |
18 | chan->completed_cookie = DMA_MIN_COOKIE; |
19 | } |
20 | |
21 | /** |
22 | * dma_cookie_assign - assign a DMA engine cookie to the descriptor |
23 | * @tx: descriptor needing cookie |
24 | * |
25 | * Assign a unique non-zero per-channel cookie to the descriptor. |
26 | * Note: caller is expected to hold a lock to prevent concurrency. |
27 | */ |
28 | static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descriptor *tx) |
29 | { |
30 | struct dma_chan *chan = tx->chan; |
31 | dma_cookie_t cookie; |
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 | |
41 | /** |
42 | * dma_cookie_complete - complete a descriptor |
43 | * @tx: descriptor to complete |
44 | * |
45 | * Mark this descriptor complete by updating the channels completed |
46 | * cookie marker. Zero the descriptors cookie to prevent accidental |
47 | * repeated completions. |
48 | * |
49 | * Note: caller is expected to hold a lock to prevent concurrency. |
50 | */ |
51 | static inline void dma_cookie_complete(struct dma_async_tx_descriptor *tx) |
52 | { |
53 | BUG_ON(tx->cookie < DMA_MIN_COOKIE); |
54 | tx->chan->completed_cookie = tx->cookie; |
55 | tx->cookie = 0; |
56 | } |
57 | |
58 | /** |
59 | * dma_cookie_status - report cookie status |
60 | * @chan: dma channel |
61 | * @cookie: cookie we are interested in |
62 | * @state: dma_tx_state structure to return last/used cookies |
63 | * |
64 | * Report the status of the cookie, filling in the state structure if |
65 | * non-NULL. No locking is required. |
66 | */ |
67 | static inline enum dma_status dma_cookie_status(struct dma_chan *chan, |
68 | dma_cookie_t cookie, struct dma_tx_state *state) |
69 | { |
70 | dma_cookie_t used, complete; |
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 |
90 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9