diff options
author | Dan Williams <dan.j.williams@intel.com> | 2010-03-26 19:52:10 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2010-03-26 19:52:10 -0400 |
commit | bca3469205402d9fb14060d255d8786ae2256640 (patch) | |
tree | 3b0c7f246fb9a6eafd3a82dd621dd9753589b3f4 | |
parent | 0793448187643b50af89d36b08470baf45a3cab4 (diff) |
dmaengine: provide helper for setting txstate
Simple conditional struct filler to cut out some duplicated code.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/dma/at_hdmac.c | 7 | ||||
-rw-r--r-- | drivers/dma/coh901318.c | 8 | ||||
-rw-r--r-- | drivers/dma/dw_dmac.c | 6 | ||||
-rw-r--r-- | drivers/dma/fsldma.c | 6 | ||||
-rw-r--r-- | drivers/dma/ioat/dma.h | 6 | ||||
-rw-r--r-- | drivers/dma/iop-adma.c | 15 | ||||
-rw-r--r-- | drivers/dma/ipu/ipu_idmac.c | 6 | ||||
-rw-r--r-- | drivers/dma/mpc512x_dma.c | 7 | ||||
-rw-r--r-- | drivers/dma/mv_xor.c | 13 | ||||
-rw-r--r-- | drivers/dma/ppc4xx/adma.c | 12 | ||||
-rw-r--r-- | drivers/dma/shdma.c | 7 | ||||
-rw-r--r-- | drivers/dma/timb_dma.c | 6 | ||||
-rw-r--r-- | drivers/dma/txx9dmac.c | 6 | ||||
-rw-r--r-- | include/linux/dmaengine.h | 10 |
14 files changed, 27 insertions, 88 deletions
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index ff75cf18d32e..93ed99c84cf1 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c | |||
@@ -834,12 +834,7 @@ atc_tx_status(struct dma_chan *chan, | |||
834 | 834 | ||
835 | spin_unlock_bh(&atchan->lock); | 835 | spin_unlock_bh(&atchan->lock); |
836 | 836 | ||
837 | if (txstate) { | 837 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
838 | txstate->last = last_complete; | ||
839 | txstate->used = last_used; | ||
840 | txstate->residue = 0; | ||
841 | } | ||
842 | |||
843 | dev_vdbg(chan2dev(chan), "tx_status: %d (d%d, u%d)\n", | 838 | dev_vdbg(chan2dev(chan), "tx_status: %d (d%d, u%d)\n", |
844 | cookie, last_complete ? last_complete : 0, | 839 | cookie, last_complete ? last_complete : 0, |
845 | last_used ? last_used : 0); | 840 | last_used ? last_used : 0); |
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c index 309db3beef16..4233440741a2 100644 --- a/drivers/dma/coh901318.c +++ b/drivers/dma/coh901318.c | |||
@@ -1147,12 +1147,8 @@ coh901318_tx_status(struct dma_chan *chan, dma_cookie_t cookie, | |||
1147 | 1147 | ||
1148 | ret = dma_async_is_complete(cookie, last_complete, last_used); | 1148 | ret = dma_async_is_complete(cookie, last_complete, last_used); |
1149 | 1149 | ||
1150 | if (txstate) { | 1150 | dma_set_tx_state(txstate, last_complete, last_used, |
1151 | txstate->last = last_complete; | 1151 | coh901318_get_bytes_left(chan)); |
1152 | txstate->used = last_used; | ||
1153 | txstate->residue = coh901318_get_bytes_left(chan); | ||
1154 | } | ||
1155 | |||
1156 | if (ret == DMA_IN_PROGRESS && cohc->stopped) | 1152 | if (ret == DMA_IN_PROGRESS && cohc->stopped) |
1157 | ret = DMA_PAUSED; | 1153 | ret = DMA_PAUSED; |
1158 | 1154 | ||
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c index 263b70ee8562..18fb5b41cedf 100644 --- a/drivers/dma/dw_dmac.c +++ b/drivers/dma/dw_dmac.c | |||
@@ -841,11 +841,7 @@ dwc_tx_status(struct dma_chan *chan, | |||
841 | ret = dma_async_is_complete(cookie, last_complete, last_used); | 841 | ret = dma_async_is_complete(cookie, last_complete, last_used); |
842 | } | 842 | } |
843 | 843 | ||
844 | if (txstate) { | 844 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
845 | txstate->last = last_complete; | ||
846 | txstate->used = last_used; | ||
847 | txstate->residue = 0; | ||
848 | } | ||
849 | 845 | ||
850 | return ret; | 846 | return ret; |
851 | } | 847 | } |
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index ca5e8a3dce72..cb1924f46c9e 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c | |||
@@ -987,11 +987,7 @@ static enum dma_status fsl_tx_status(struct dma_chan *dchan, | |||
987 | last_used = dchan->cookie; | 987 | last_used = dchan->cookie; |
988 | last_complete = chan->completed_cookie; | 988 | last_complete = chan->completed_cookie; |
989 | 989 | ||
990 | if (txstate) { | 990 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
991 | txstate->last = last_complete; | ||
992 | txstate->used = last_used; | ||
993 | txstate->residue = 0; | ||
994 | } | ||
995 | 991 | ||
996 | return dma_async_is_complete(cookie, last_complete, last_used); | 992 | return dma_async_is_complete(cookie, last_complete, last_used); |
997 | } | 993 | } |
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h index 23399672239e..26f48ef94c5c 100644 --- a/drivers/dma/ioat/dma.h +++ b/drivers/dma/ioat/dma.h | |||
@@ -158,11 +158,7 @@ ioat_tx_status(struct dma_chan *c, dma_cookie_t cookie, | |||
158 | last_used = c->cookie; | 158 | last_used = c->cookie; |
159 | last_complete = chan->completed_cookie; | 159 | last_complete = chan->completed_cookie; |
160 | 160 | ||
161 | if (txstate) { | 161 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
162 | txstate->last = last_complete; | ||
163 | txstate->used = last_used; | ||
164 | txstate->residue = 0; | ||
165 | } | ||
166 | 162 | ||
167 | return dma_async_is_complete(cookie, last_complete, last_used); | 163 | return dma_async_is_complete(cookie, last_complete, last_used); |
168 | } | 164 | } |
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c index ee40dbba1879..e5d4b97b7fd5 100644 --- a/drivers/dma/iop-adma.c +++ b/drivers/dma/iop-adma.c | |||
@@ -909,13 +909,7 @@ static enum dma_status iop_adma_status(struct dma_chan *chan, | |||
909 | 909 | ||
910 | last_used = chan->cookie; | 910 | last_used = chan->cookie; |
911 | last_complete = iop_chan->completed_cookie; | 911 | last_complete = iop_chan->completed_cookie; |
912 | 912 | dma_set_tx_state(txstate, last_complete, last_used, 0); | |
913 | if (txstate) { | ||
914 | txstate->last = last_complete; | ||
915 | txstate->used = last_used; | ||
916 | txstate->residue = 0; | ||
917 | } | ||
918 | |||
919 | ret = dma_async_is_complete(cookie, last_complete, last_used); | 913 | ret = dma_async_is_complete(cookie, last_complete, last_used); |
920 | if (ret == DMA_SUCCESS) | 914 | if (ret == DMA_SUCCESS) |
921 | return ret; | 915 | return ret; |
@@ -924,12 +918,7 @@ static enum dma_status iop_adma_status(struct dma_chan *chan, | |||
924 | 918 | ||
925 | last_used = chan->cookie; | 919 | last_used = chan->cookie; |
926 | last_complete = iop_chan->completed_cookie; | 920 | last_complete = iop_chan->completed_cookie; |
927 | 921 | dma_set_tx_state(txstate, last_complete, last_used, 0); | |
928 | if (txstate) { | ||
929 | txstate->last = last_complete; | ||
930 | txstate->used = last_used; | ||
931 | txstate->residue = 0; | ||
932 | } | ||
933 | 922 | ||
934 | return dma_async_is_complete(cookie, last_complete, last_used); | 923 | return dma_async_is_complete(cookie, last_complete, last_used); |
935 | } | 924 | } |
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index b9cef8b1701c..246a6143e4a7 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c | |||
@@ -1651,11 +1651,7 @@ static enum dma_status idmac_tx_status(struct dma_chan *chan, | |||
1651 | { | 1651 | { |
1652 | struct idmac_channel *ichan = to_idmac_chan(chan); | 1652 | struct idmac_channel *ichan = to_idmac_chan(chan); |
1653 | 1653 | ||
1654 | if (txstate) { | 1654 | dma_set_tx_state(txstate, ichan->completed, chan->cookie, 0); |
1655 | txstate->last = ichan->completed; | ||
1656 | txstate->used = chan->cookie; | ||
1657 | txstate->residue = 0; | ||
1658 | } | ||
1659 | if (cookie != chan->cookie) | 1655 | if (cookie != chan->cookie) |
1660 | return DMA_ERROR; | 1656 | return DMA_ERROR; |
1661 | return DMA_SUCCESS; | 1657 | return DMA_SUCCESS; |
diff --git a/drivers/dma/mpc512x_dma.c b/drivers/dma/mpc512x_dma.c index cb3a8e94ea48..7a750b95303c 100644 --- a/drivers/dma/mpc512x_dma.c +++ b/drivers/dma/mpc512x_dma.c | |||
@@ -553,12 +553,7 @@ mpc_dma_tx_status(struct dma_chan *chan, dma_cookie_t cookie, | |||
553 | last_complete = mchan->completed_cookie; | 553 | last_complete = mchan->completed_cookie; |
554 | spin_unlock_irqrestore(&mchan->lock, flags); | 554 | spin_unlock_irqrestore(&mchan->lock, flags); |
555 | 555 | ||
556 | if (txstate) { | 556 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
557 | txstate->last = last_complete; | ||
558 | txstate->used = last_used; | ||
559 | txstate->residue = 0; | ||
560 | } | ||
561 | |||
562 | return dma_async_is_complete(cookie, last_complete, last_used); | 557 | return dma_async_is_complete(cookie, last_complete, last_used); |
563 | } | 558 | } |
564 | 559 | ||
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index 79fb1dea691b..4b8c1fcc834d 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c | |||
@@ -826,11 +826,7 @@ static enum dma_status mv_xor_status(struct dma_chan *chan, | |||
826 | last_used = chan->cookie; | 826 | last_used = chan->cookie; |
827 | last_complete = mv_chan->completed_cookie; | 827 | last_complete = mv_chan->completed_cookie; |
828 | mv_chan->is_complete_cookie = cookie; | 828 | mv_chan->is_complete_cookie = cookie; |
829 | if (txstate) { | 829 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
830 | txstate->last = last_complete; | ||
831 | txstate->used = last_used; | ||
832 | txstate->residue = 0; | ||
833 | } | ||
834 | 830 | ||
835 | ret = dma_async_is_complete(cookie, last_complete, last_used); | 831 | ret = dma_async_is_complete(cookie, last_complete, last_used); |
836 | if (ret == DMA_SUCCESS) { | 832 | if (ret == DMA_SUCCESS) { |
@@ -842,12 +838,7 @@ static enum dma_status mv_xor_status(struct dma_chan *chan, | |||
842 | last_used = chan->cookie; | 838 | last_used = chan->cookie; |
843 | last_complete = mv_chan->completed_cookie; | 839 | last_complete = mv_chan->completed_cookie; |
844 | 840 | ||
845 | if (txstate) { | 841 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
846 | txstate->last = last_complete; | ||
847 | txstate->used = last_used; | ||
848 | txstate->residue = 0; | ||
849 | } | ||
850 | |||
851 | return dma_async_is_complete(cookie, last_complete, last_used); | 842 | return dma_async_is_complete(cookie, last_complete, last_used); |
852 | } | 843 | } |
853 | 844 | ||
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c index d9a54c018652..5558419876e8 100644 --- a/drivers/dma/ppc4xx/adma.c +++ b/drivers/dma/ppc4xx/adma.c | |||
@@ -3951,11 +3951,7 @@ static enum dma_status ppc440spe_adma_tx_status(struct dma_chan *chan, | |||
3951 | last_used = chan->cookie; | 3951 | last_used = chan->cookie; |
3952 | last_complete = ppc440spe_chan->completed_cookie; | 3952 | last_complete = ppc440spe_chan->completed_cookie; |
3953 | 3953 | ||
3954 | if (txstate) { | 3954 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
3955 | txstate->last = last_complete; | ||
3956 | txstate->used = last_used; | ||
3957 | txstate->residue = 0; | ||
3958 | } | ||
3959 | 3955 | ||
3960 | ret = dma_async_is_complete(cookie, last_complete, last_used); | 3956 | ret = dma_async_is_complete(cookie, last_complete, last_used); |
3961 | if (ret == DMA_SUCCESS) | 3957 | if (ret == DMA_SUCCESS) |
@@ -3966,11 +3962,7 @@ static enum dma_status ppc440spe_adma_tx_status(struct dma_chan *chan, | |||
3966 | last_used = chan->cookie; | 3962 | last_used = chan->cookie; |
3967 | last_complete = ppc440spe_chan->completed_cookie; | 3963 | last_complete = ppc440spe_chan->completed_cookie; |
3968 | 3964 | ||
3969 | if (txstate) { | 3965 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
3970 | txstate->last = last_complete; | ||
3971 | txstate->used = last_used; | ||
3972 | txstate->residue = 0; | ||
3973 | } | ||
3974 | 3966 | ||
3975 | return dma_async_is_complete(cookie, last_complete, last_used); | 3967 | return dma_async_is_complete(cookie, last_complete, last_used); |
3976 | } | 3968 | } |
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c index 8aeda9ceb225..98f82cdb404c 100644 --- a/drivers/dma/shdma.c +++ b/drivers/dma/shdma.c | |||
@@ -752,12 +752,7 @@ static enum dma_status sh_dmae_tx_status(struct dma_chan *chan, | |||
752 | last_used = chan->cookie; | 752 | last_used = chan->cookie; |
753 | last_complete = sh_chan->completed_cookie; | 753 | last_complete = sh_chan->completed_cookie; |
754 | BUG_ON(last_complete < 0); | 754 | BUG_ON(last_complete < 0); |
755 | 755 | dma_set_tx_state(txstate, last_complete, last_used, 0); | |
756 | if (txstate) { | ||
757 | txstate->last = last_complete; | ||
758 | txstate->used = last_used; | ||
759 | txstate->residue = 0; | ||
760 | } | ||
761 | 756 | ||
762 | spin_lock_bh(&sh_chan->desc_lock); | 757 | spin_lock_bh(&sh_chan->desc_lock); |
763 | 758 | ||
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c index 8fc28814561a..e20d5c1fa213 100644 --- a/drivers/dma/timb_dma.c +++ b/drivers/dma/timb_dma.c | |||
@@ -527,11 +527,7 @@ static enum dma_status td_tx_status(struct dma_chan *chan, dma_cookie_t cookie, | |||
527 | 527 | ||
528 | ret = dma_async_is_complete(cookie, last_complete, last_used); | 528 | ret = dma_async_is_complete(cookie, last_complete, last_used); |
529 | 529 | ||
530 | if (txstate) { | 530 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
531 | txstate->last = last_complete; | ||
532 | txstate->used = last_used; | ||
533 | txstate->residue = 0; | ||
534 | } | ||
535 | 531 | ||
536 | dev_dbg(chan2dev(chan), | 532 | dev_dbg(chan2dev(chan), |
537 | "%s: exit, ret: %d, last_complete: %d, last_used: %d\n", | 533 | "%s: exit, ret: %d, last_complete: %d, last_used: %d\n", |
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c index a44e422cbc27..e523737639aa 100644 --- a/drivers/dma/txx9dmac.c +++ b/drivers/dma/txx9dmac.c | |||
@@ -990,11 +990,7 @@ txx9dmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, | |||
990 | ret = dma_async_is_complete(cookie, last_complete, last_used); | 990 | ret = dma_async_is_complete(cookie, last_complete, last_used); |
991 | } | 991 | } |
992 | 992 | ||
993 | if (txstate) { | 993 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
994 | txstate->last = last_complete; | ||
995 | txstate->used = last_used; | ||
996 | txstate->residue = 0; | ||
997 | } | ||
998 | 994 | ||
999 | return ret; | 995 | return ret; |
1000 | } | 996 | } |
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 55b08e84ac8d..50b7b3e0d572 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
@@ -628,6 +628,16 @@ static inline enum dma_status dma_async_is_complete(dma_cookie_t cookie, | |||
628 | return DMA_IN_PROGRESS; | 628 | return DMA_IN_PROGRESS; |
629 | } | 629 | } |
630 | 630 | ||
631 | static inline void | ||
632 | dma_set_tx_state(struct dma_tx_state *st, dma_cookie_t last, dma_cookie_t used, u32 residue) | ||
633 | { | ||
634 | if (st) { | ||
635 | st->last = last; | ||
636 | st->used = used; | ||
637 | st->residue = residue; | ||
638 | } | ||
639 | } | ||
640 | |||
631 | enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie); | 641 | enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie); |
632 | #ifdef CONFIG_DMA_ENGINE | 642 | #ifdef CONFIG_DMA_ENGINE |
633 | enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx); | 643 | enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx); |