dmaengine/dw_dmac: Reconfigure interrupt and chan_cfg register on resume
[linux-2.6.git] / drivers / dma / timb_dma.c
index 464fad5..49e5b02 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <linux/timb_dma.h>
 
+#include "dmaengine.h"
+
 #define DRIVER_NAME "timb-dma"
 
 /* Global DMA registers */
@@ -84,7 +86,6 @@ struct timb_dma_chan {
                                        especially the lists and descriptors,
                                        from races between the tasklet and calls
                                        from above */
-       dma_cookie_t            last_completed_cookie;
        bool                    ongoing;
        struct list_head        active_list;
        struct list_head        queue;
@@ -284,7 +285,7 @@ static void __td_finish(struct timb_dma_chan *td_chan)
        else
                iowrite32(0, td_chan->membase + TIMBDMA_OFFS_TX_DLAR);
 */
-       td_chan->last_completed_cookie = txd->cookie;
+       dma_cookie_complete(txd);
        td_chan->ongoing = false;
 
        callback = txd->callback;
@@ -349,12 +350,7 @@ static dma_cookie_t td_tx_submit(struct dma_async_tx_descriptor *txd)
        dma_cookie_t cookie;
 
        spin_lock_bh(&td_chan->lock);
-
-       cookie = txd->chan->cookie;
-       if (++cookie < 0)
-               cookie = 1;
-       txd->chan->cookie = cookie;
-       txd->cookie = cookie;
+       cookie = dma_cookie_assign(txd);
 
        if (list_empty(&td_chan->active_list)) {
                dev_dbg(chan2dev(txd->chan), "%s: started %u\n", __func__,
@@ -382,7 +378,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
        td_desc = kzalloc(sizeof(struct timb_dma_desc), GFP_KERNEL);
        if (!td_desc) {
                dev_err(chan2dev(chan), "Failed to alloc descriptor\n");
-               goto err;
+               goto out;
        }
 
        td_desc->desc_list_len = td_chan->desc_elems * TIMB_DMA_DESC_SIZE;
@@ -410,7 +406,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
 err:
        kfree(td_desc->desc_list);
        kfree(td_desc);
-
+out:
        return NULL;
 
 }
@@ -481,8 +477,7 @@ static int td_alloc_chan_resources(struct dma_chan *chan)
        }
 
        spin_lock_bh(&td_chan->lock);
-       td_chan->last_completed_cookie = 1;
-       chan->cookie = 1;
+       dma_cookie_init(chan);
        spin_unlock_bh(&td_chan->lock);
 
        return 0;
@@ -517,18 +512,11 @@ static enum dma_status td_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
 {
        struct timb_dma_chan *td_chan =
                container_of(chan, struct timb_dma_chan, chan);
-       dma_cookie_t            last_used;
-       dma_cookie_t            last_complete;
-       int                     ret;
+       enum dma_status ret;
 
        dev_dbg(chan2dev(chan), "%s: Entry\n", __func__);
 
-       last_complete = td_chan->last_completed_cookie;
-       last_used = chan->cookie;
-
-       ret = dma_async_is_complete(cookie, last_complete, last_used);
-
-       dma_set_tx_state(txstate, last_complete, last_used, 0);
+       ret = dma_cookie_status(chan, cookie, txstate);
 
        dev_dbg(chan2dev(chan),
                "%s: exit, ret: %d, last_complete: %d, last_used: %d\n",
@@ -629,7 +617,7 @@ static int td_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
                desc_node)
                list_move(&td_desc->desc_node, &td_chan->free_list);
 
-       /* now tear down the runnning */
+       /* now tear down the running */
        __td_finish(td_chan);
        spin_unlock_bh(&td_chan->lock);
 
@@ -759,15 +747,19 @@ static int __devinit td_probe(struct platform_device *pdev)
                        pdata->channels + i;
 
                /* even channels are RX, odd are TX */
-               if (((i % 2) && pchan->rx) || (!(i % 2) && !pchan->rx)) {
+               if ((i % 2) == pchan->rx) {
                        dev_err(&pdev->dev, "Wrong channel configuration\n");
                        err = -EINVAL;
                        goto err_tasklet_kill;
                }
 
                td_chan->chan.device = &td->dma;
+<<<<<<< HEAD
                td_chan->chan.cookie = 1;
                td_chan->chan.chan_id = i;
+=======
+               dma_cookie_init(&td_chan->chan);
+>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
                spin_lock_init(&td_chan->lock);
                INIT_LIST_HEAD(&td_chan->active_list);
                INIT_LIST_HEAD(&td_chan->queue);