diff options
author | Nicolas Ferre <nicolas.ferre@atmel.com> | 2011-07-25 17:09:23 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2011-08-19 09:09:59 -0400 |
commit | 3c477482bb9f976e5451c50be7d3d60ea6f88646 (patch) | |
tree | 55bf7f439aed1e3fc5b691777c18cbb98dde0669 /drivers/dma/at_hdmac.c | |
parent | c0ba5947370a0900b1823922fc4faf41515bc901 (diff) |
dmaengine: at_hdmac: add wrappers for testing channel state
Cyclic property and paused state are encoded as bits in the channel status
bitfield. Tests of those bits are wrapped in convenient helper functions.
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/at_hdmac.c')
-rw-r--r-- | drivers/dma/at_hdmac.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 0ead008e3bdf..d774800b9fa4 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c | |||
@@ -301,7 +301,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc) | |||
301 | 301 | ||
302 | /* for cyclic transfers, | 302 | /* for cyclic transfers, |
303 | * no need to replay callback function while stopping */ | 303 | * no need to replay callback function while stopping */ |
304 | if (!test_bit(ATC_IS_CYCLIC, &atchan->status)) { | 304 | if (!atc_chan_is_cyclic(atchan)) { |
305 | dma_async_tx_callback callback = txd->callback; | 305 | dma_async_tx_callback callback = txd->callback; |
306 | void *param = txd->callback_param; | 306 | void *param = txd->callback_param; |
307 | 307 | ||
@@ -478,7 +478,7 @@ static void atc_tasklet(unsigned long data) | |||
478 | spin_lock_irqsave(&atchan->lock, flags); | 478 | spin_lock_irqsave(&atchan->lock, flags); |
479 | if (test_and_clear_bit(ATC_IS_ERROR, &atchan->status)) | 479 | if (test_and_clear_bit(ATC_IS_ERROR, &atchan->status)) |
480 | atc_handle_error(atchan); | 480 | atc_handle_error(atchan); |
481 | else if (test_bit(ATC_IS_CYCLIC, &atchan->status)) | 481 | else if (atc_chan_is_cyclic(atchan)) |
482 | atc_handle_cyclic(atchan); | 482 | atc_handle_cyclic(atchan); |
483 | else | 483 | else |
484 | atc_advance_work(atchan); | 484 | atc_advance_work(atchan); |
@@ -945,7 +945,7 @@ static int atc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, | |||
945 | 945 | ||
946 | spin_unlock_irqrestore(&atchan->lock, flags); | 946 | spin_unlock_irqrestore(&atchan->lock, flags); |
947 | } else if (cmd == DMA_RESUME) { | 947 | } else if (cmd == DMA_RESUME) { |
948 | if (!test_bit(ATC_IS_PAUSED, &atchan->status)) | 948 | if (!atc_chan_is_paused(atchan)) |
949 | return 0; | 949 | return 0; |
950 | 950 | ||
951 | spin_lock_irqsave(&atchan->lock, flags); | 951 | spin_lock_irqsave(&atchan->lock, flags); |
@@ -1035,7 +1035,7 @@ atc_tx_status(struct dma_chan *chan, | |||
1035 | else | 1035 | else |
1036 | dma_set_tx_state(txstate, last_complete, last_used, 0); | 1036 | dma_set_tx_state(txstate, last_complete, last_used, 0); |
1037 | 1037 | ||
1038 | if (test_bit(ATC_IS_PAUSED, &atchan->status)) | 1038 | if (atc_chan_is_paused(atchan)) |
1039 | ret = DMA_PAUSED; | 1039 | ret = DMA_PAUSED; |
1040 | 1040 | ||
1041 | dev_vdbg(chan2dev(chan), "tx_status %d: cookie = %d (d%d, u%d)\n", | 1041 | dev_vdbg(chan2dev(chan), "tx_status %d: cookie = %d (d%d, u%d)\n", |
@@ -1057,7 +1057,7 @@ static void atc_issue_pending(struct dma_chan *chan) | |||
1057 | dev_vdbg(chan2dev(chan), "issue_pending\n"); | 1057 | dev_vdbg(chan2dev(chan), "issue_pending\n"); |
1058 | 1058 | ||
1059 | /* Not needed for cyclic transfers */ | 1059 | /* Not needed for cyclic transfers */ |
1060 | if (test_bit(ATC_IS_CYCLIC, &atchan->status)) | 1060 | if (atc_chan_is_cyclic(atchan)) |
1061 | return; | 1061 | return; |
1062 | 1062 | ||
1063 | spin_lock_irqsave(&atchan->lock, flags); | 1063 | spin_lock_irqsave(&atchan->lock, flags); |
@@ -1395,8 +1395,7 @@ static int at_dma_prepare(struct device *dev) | |||
1395 | device_node) { | 1395 | device_node) { |
1396 | struct at_dma_chan *atchan = to_at_dma_chan(chan); | 1396 | struct at_dma_chan *atchan = to_at_dma_chan(chan); |
1397 | /* wait for transaction completion (except in cyclic case) */ | 1397 | /* wait for transaction completion (except in cyclic case) */ |
1398 | if (atc_chan_is_enabled(atchan) && | 1398 | if (atc_chan_is_enabled(atchan) && !atc_chan_is_cyclic(atchan)) |
1399 | !test_bit(ATC_IS_CYCLIC, &atchan->status)) | ||
1400 | return -EAGAIN; | 1399 | return -EAGAIN; |
1401 | } | 1400 | } |
1402 | return 0; | 1401 | return 0; |
@@ -1408,7 +1407,7 @@ static void atc_suspend_cyclic(struct at_dma_chan *atchan) | |||
1408 | 1407 | ||
1409 | /* Channel should be paused by user | 1408 | /* Channel should be paused by user |
1410 | * do it anyway even if it is not done already */ | 1409 | * do it anyway even if it is not done already */ |
1411 | if (!test_bit(ATC_IS_PAUSED, &atchan->status)) { | 1410 | if (!atc_chan_is_paused(atchan)) { |
1412 | dev_warn(chan2dev(chan), | 1411 | dev_warn(chan2dev(chan), |
1413 | "cyclic channel not paused, should be done by channel user\n"); | 1412 | "cyclic channel not paused, should be done by channel user\n"); |
1414 | atc_control(chan, DMA_PAUSE, 0); | 1413 | atc_control(chan, DMA_PAUSE, 0); |
@@ -1432,7 +1431,7 @@ static int at_dma_suspend_noirq(struct device *dev) | |||
1432 | device_node) { | 1431 | device_node) { |
1433 | struct at_dma_chan *atchan = to_at_dma_chan(chan); | 1432 | struct at_dma_chan *atchan = to_at_dma_chan(chan); |
1434 | 1433 | ||
1435 | if (test_bit(ATC_IS_CYCLIC, &atchan->status)) | 1434 | if (atc_chan_is_cyclic(atchan)) |
1436 | atc_suspend_cyclic(atchan); | 1435 | atc_suspend_cyclic(atchan); |
1437 | atchan->save_cfg = channel_readl(atchan, CFG); | 1436 | atchan->save_cfg = channel_readl(atchan, CFG); |
1438 | } | 1437 | } |
@@ -1484,7 +1483,7 @@ static int at_dma_resume_noirq(struct device *dev) | |||
1484 | struct at_dma_chan *atchan = to_at_dma_chan(chan); | 1483 | struct at_dma_chan *atchan = to_at_dma_chan(chan); |
1485 | 1484 | ||
1486 | channel_writel(atchan, CFG, atchan->save_cfg); | 1485 | channel_writel(atchan, CFG, atchan->save_cfg); |
1487 | if (test_bit(ATC_IS_CYCLIC, &atchan->status)) | 1486 | if (atc_chan_is_cyclic(atchan)) |
1488 | atc_resume_cyclic(atchan); | 1487 | atc_resume_cyclic(atchan); |
1489 | } | 1488 | } |
1490 | return 0; | 1489 | return 0; |