Russell King - ARM Linux | d2ebfb3 | 2012-03-06 22:34:26 +0000 | [diff] [blame] | 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 | |
Russell King - ARM Linux | f7fbce0 | 2012-03-06 22:35:07 +0000 | [diff] [blame^] | 8 | #include <linux/bug.h> |
Russell King - ARM Linux | d2ebfb3 | 2012-03-06 22:34:26 +0000 | [diff] [blame] | 9 | #include <linux/dmaengine.h> |
| 10 | |
Russell King - ARM Linux | 884485e | 2012-03-06 22:34:46 +0000 | [diff] [blame] | 11 | /** |
| 12 | * dma_cookie_assign - assign a DMA engine cookie to the descriptor |
| 13 | * @tx: descriptor needing cookie |
| 14 | * |
| 15 | * Assign a unique non-zero per-channel cookie to the descriptor. |
| 16 | * Note: caller is expected to hold a lock to prevent concurrency. |
| 17 | */ |
| 18 | static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descriptor *tx) |
| 19 | { |
| 20 | struct dma_chan *chan = tx->chan; |
| 21 | dma_cookie_t cookie; |
| 22 | |
| 23 | cookie = chan->cookie + 1; |
| 24 | if (cookie < DMA_MIN_COOKIE) |
| 25 | cookie = DMA_MIN_COOKIE; |
| 26 | tx->cookie = chan->cookie = cookie; |
| 27 | |
| 28 | return cookie; |
| 29 | } |
| 30 | |
Russell King - ARM Linux | f7fbce0 | 2012-03-06 22:35:07 +0000 | [diff] [blame^] | 31 | /** |
| 32 | * dma_cookie_complete - complete a descriptor |
| 33 | * @tx: descriptor to complete |
| 34 | * |
| 35 | * Mark this descriptor complete by updating the channels completed |
| 36 | * cookie marker. Zero the descriptors cookie to prevent accidental |
| 37 | * repeated completions. |
| 38 | * |
| 39 | * Note: caller is expected to hold a lock to prevent concurrency. |
| 40 | */ |
| 41 | static inline void dma_cookie_complete(struct dma_async_tx_descriptor *tx) |
| 42 | { |
| 43 | BUG_ON(tx->cookie < DMA_MIN_COOKIE); |
| 44 | tx->chan->completed_cookie = tx->cookie; |
| 45 | tx->cookie = 0; |
| 46 | } |
| 47 | |
Russell King - ARM Linux | d2ebfb3 | 2012-03-06 22:34:26 +0000 | [diff] [blame] | 48 | #endif |