]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
dmaengine: at_hdmac: add wrappers for testing channel state
authorNicolas Ferre <nicolas.ferre@atmel.com>
Mon, 25 Jul 2011 21:09:23 +0000 (21:09 +0000)
committerVinod Koul <vinod.koul@intel.com>
Fri, 19 Aug 2011 13:09:59 +0000 (18:39 +0530)
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>
drivers/dma/at_hdmac.c
drivers/dma/at_hdmac_regs.h

index 0ead008e3bdfa8a5bd0d95b6b668b6e5027b174f..d774800b9fa454250c9059158d083445b1fe256b 100644 (file)
@@ -301,7 +301,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc)
 
        /* for cyclic transfers,
         * no need to replay callback function while stopping */
-       if (!test_bit(ATC_IS_CYCLIC, &atchan->status)) {
+       if (!atc_chan_is_cyclic(atchan)) {
                dma_async_tx_callback   callback = txd->callback;
                void                    *param = txd->callback_param;
 
@@ -478,7 +478,7 @@ static void atc_tasklet(unsigned long data)
        spin_lock_irqsave(&atchan->lock, flags);
        if (test_and_clear_bit(ATC_IS_ERROR, &atchan->status))
                atc_handle_error(atchan);
-       else if (test_bit(ATC_IS_CYCLIC, &atchan->status))
+       else if (atc_chan_is_cyclic(atchan))
                atc_handle_cyclic(atchan);
        else
                atc_advance_work(atchan);
@@ -945,7 +945,7 @@ static int atc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
 
                spin_unlock_irqrestore(&atchan->lock, flags);
        } else if (cmd == DMA_RESUME) {
-               if (!test_bit(ATC_IS_PAUSED, &atchan->status))
+               if (!atc_chan_is_paused(atchan))
                        return 0;
 
                spin_lock_irqsave(&atchan->lock, flags);
@@ -1035,7 +1035,7 @@ atc_tx_status(struct dma_chan *chan,
        else
                dma_set_tx_state(txstate, last_complete, last_used, 0);
 
-       if (test_bit(ATC_IS_PAUSED, &atchan->status))
+       if (atc_chan_is_paused(atchan))
                ret = DMA_PAUSED;
 
        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)
        dev_vdbg(chan2dev(chan), "issue_pending\n");
 
        /* Not needed for cyclic transfers */
-       if (test_bit(ATC_IS_CYCLIC, &atchan->status))
+       if (atc_chan_is_cyclic(atchan))
                return;
 
        spin_lock_irqsave(&atchan->lock, flags);
@@ -1395,8 +1395,7 @@ static int at_dma_prepare(struct device *dev)
                        device_node) {
                struct at_dma_chan *atchan = to_at_dma_chan(chan);
                /* wait for transaction completion (except in cyclic case) */
-               if (atc_chan_is_enabled(atchan) &&
-                  !test_bit(ATC_IS_CYCLIC, &atchan->status))
+               if (atc_chan_is_enabled(atchan) && !atc_chan_is_cyclic(atchan))
                        return -EAGAIN;
        }
        return 0;
@@ -1408,7 +1407,7 @@ static void atc_suspend_cyclic(struct at_dma_chan *atchan)
 
        /* Channel should be paused by user
         * do it anyway even if it is not done already */
-       if (!test_bit(ATC_IS_PAUSED, &atchan->status)) {
+       if (!atc_chan_is_paused(atchan)) {
                dev_warn(chan2dev(chan),
                "cyclic channel not paused, should be done by channel user\n");
                atc_control(chan, DMA_PAUSE, 0);
@@ -1432,7 +1431,7 @@ static int at_dma_suspend_noirq(struct device *dev)
                        device_node) {
                struct at_dma_chan *atchan = to_at_dma_chan(chan);
 
-               if (test_bit(ATC_IS_CYCLIC, &atchan->status))
+               if (atc_chan_is_cyclic(atchan))
                        atc_suspend_cyclic(atchan);
                atchan->save_cfg = channel_readl(atchan, CFG);
        }
@@ -1484,7 +1483,7 @@ static int at_dma_resume_noirq(struct device *dev)
                struct at_dma_chan *atchan = to_at_dma_chan(chan);
 
                channel_writel(atchan, CFG, atchan->save_cfg);
-               if (test_bit(ATC_IS_CYCLIC, &atchan->status))
+               if (atc_chan_is_cyclic(atchan))
                        atc_resume_cyclic(atchan);
        }
        return 0;
index 6f0c4a3eb091c31babff8968ab22675510e1d88e..aa4c9aebab7cedec68a42aececeb218aaea0208b 100644 (file)
@@ -362,6 +362,23 @@ static inline int atc_chan_is_enabled(struct at_dma_chan *atchan)
        return !!(dma_readl(atdma, CHSR) & atchan->mask);
 }
 
+/**
+ * atc_chan_is_paused - test channel pause/resume status
+ * @atchan: channel we want to test status
+ */
+static inline int atc_chan_is_paused(struct at_dma_chan *atchan)
+{
+       return test_bit(ATC_IS_PAUSED, &atchan->status);
+}
+
+/**
+ * atc_chan_is_cyclic - test if given channel has cyclic property set
+ * @atchan: channel we want to test status
+ */
+static inline int atc_chan_is_cyclic(struct at_dma_chan *atchan)
+{
+       return test_bit(ATC_IS_CYCLIC, &atchan->status);
+}
 
 /**
  * set_desc_eol - set end-of-link to descriptor so it will end transfer