diff options
author | Russell King - ARM Linux <linux@arm.linux.org.uk> | 2012-03-06 17:35:47 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@linux.intel.com> | 2012-03-13 02:07:22 -0400 |
commit | d3ee98cdcd6198ea1cf75c603178acc8a805b69b (patch) | |
tree | 721f252d07d5e0596fa9b58a7c876dfd75823d0a /drivers | |
parent | 96a2af41c78b1fbb1f567a3486bdc63f7b31c5fd (diff) |
dmaengine: consolidate initialization of cookies
Provide a common function to initialize a channels cookie values.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
[imx-sdma.c & mxs-dma.c]
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 3 | ||||
-rw-r--r-- | drivers/dma/at_hdmac.c | 4 | ||||
-rw-r--r-- | drivers/dma/coh901318.c | 2 | ||||
-rw-r--r-- | drivers/dma/dmaengine.h | 10 | ||||
-rw-r--r-- | drivers/dma/dw_dmac.c | 4 | ||||
-rw-r--r-- | drivers/dma/ep93xx_dma.c | 3 | ||||
-rw-r--r-- | drivers/dma/intel_mid_dma.c | 4 | ||||
-rw-r--r-- | drivers/dma/ipu/ipu_idmac.c | 6 | ||||
-rw-r--r-- | drivers/dma/mpc512x_dma.c | 3 | ||||
-rw-r--r-- | drivers/dma/pch_dma.c | 4 | ||||
-rw-r--r-- | drivers/dma/pl330.c | 2 | ||||
-rw-r--r-- | drivers/dma/sirf-dma.c | 3 | ||||
-rw-r--r-- | drivers/dma/ste_dma40.c | 2 | ||||
-rw-r--r-- | drivers/dma/timb_dma.c | 5 | ||||
-rw-r--r-- | drivers/dma/txx9dmac.c | 4 |
15 files changed, 31 insertions, 28 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index 810f696eda4e..1b53f2605250 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -1709,8 +1709,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x, | |||
1709 | chan->name); | 1709 | chan->name); |
1710 | 1710 | ||
1711 | chan->chan.device = dmadev; | 1711 | chan->chan.device = dmadev; |
1712 | chan->chan.cookie = 0; | 1712 | dma_cookie_init(&chan->chan); |
1713 | chan->chan.completed_cookie = 0; | ||
1714 | 1713 | ||
1715 | spin_lock_init(&chan->lock); | 1714 | spin_lock_init(&chan->lock); |
1716 | INIT_LIST_HEAD(&chan->pend_list); | 1715 | INIT_LIST_HEAD(&chan->pend_list); |
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 8a3297418cf0..5d225ddc7698 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c | |||
@@ -1103,7 +1103,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan) | |||
1103 | spin_lock_irqsave(&atchan->lock, flags); | 1103 | spin_lock_irqsave(&atchan->lock, flags); |
1104 | atchan->descs_allocated = i; | 1104 | atchan->descs_allocated = i; |
1105 | list_splice(&tmp_list, &atchan->free_list); | 1105 | list_splice(&tmp_list, &atchan->free_list); |
1106 | chan->completed_cookie = chan->cookie = 1; | 1106 | dma_cookie_init(chan); |
1107 | spin_unlock_irqrestore(&atchan->lock, flags); | 1107 | spin_unlock_irqrestore(&atchan->lock, flags); |
1108 | 1108 | ||
1109 | /* channel parameters */ | 1109 | /* channel parameters */ |
@@ -1303,7 +1303,7 @@ static int __init at_dma_probe(struct platform_device *pdev) | |||
1303 | struct at_dma_chan *atchan = &atdma->chan[i]; | 1303 | struct at_dma_chan *atchan = &atdma->chan[i]; |
1304 | 1304 | ||
1305 | atchan->chan_common.device = &atdma->dma_common; | 1305 | atchan->chan_common.device = &atdma->dma_common; |
1306 | atchan->chan_common.cookie = atchan->chan_common.completed_cookie = 1; | 1306 | dma_cookie_init(&atchan->chan_common); |
1307 | list_add_tail(&atchan->chan_common.device_node, | 1307 | list_add_tail(&atchan->chan_common.device_node, |
1308 | &atdma->dma_common.channels); | 1308 | &atdma->dma_common.channels); |
1309 | 1309 | ||
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c index f3505178ff41..187bb9eef4a2 100644 --- a/drivers/dma/coh901318.c +++ b/drivers/dma/coh901318.c | |||
@@ -915,7 +915,7 @@ static int coh901318_alloc_chan_resources(struct dma_chan *chan) | |||
915 | coh901318_config(cohc, NULL); | 915 | coh901318_config(cohc, NULL); |
916 | 916 | ||
917 | cohc->allocated = 1; | 917 | cohc->allocated = 1; |
918 | chan->completed_cookie = chan->cookie = 1; | 918 | dma_cookie_init(chan); |
919 | 919 | ||
920 | spin_unlock_irqrestore(&cohc->lock, flags); | 920 | spin_unlock_irqrestore(&cohc->lock, flags); |
921 | 921 | ||
diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h index 1ca5e0e633f4..17f983a4e9ba 100644 --- a/drivers/dma/dmaengine.h +++ b/drivers/dma/dmaengine.h | |||
@@ -9,6 +9,16 @@ | |||
9 | #include <linux/dmaengine.h> | 9 | #include <linux/dmaengine.h> |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * dma_cookie_init - initialize the cookies for a DMA channel | ||
13 | * @chan: dma channel to initialize | ||
14 | */ | ||
15 | static inline void dma_cookie_init(struct dma_chan *chan) | ||
16 | { | ||
17 | chan->cookie = DMA_MIN_COOKIE; | ||
18 | chan->completed_cookie = DMA_MIN_COOKIE; | ||
19 | } | ||
20 | |||
21 | /** | ||
12 | * dma_cookie_assign - assign a DMA engine cookie to the descriptor | 22 | * dma_cookie_assign - assign a DMA engine cookie to the descriptor |
13 | * @tx: descriptor needing cookie | 23 | * @tx: descriptor needing cookie |
14 | * | 24 | * |
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c index 33bde5da850d..cb173bbdcfdf 100644 --- a/drivers/dma/dw_dmac.c +++ b/drivers/dma/dw_dmac.c | |||
@@ -1021,7 +1021,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan) | |||
1021 | return -EIO; | 1021 | return -EIO; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | chan->completed_cookie = chan->cookie = 1; | 1024 | dma_cookie_init(chan); |
1025 | 1025 | ||
1026 | /* | 1026 | /* |
1027 | * NOTE: some controllers may have additional features that we | 1027 | * NOTE: some controllers may have additional features that we |
@@ -1449,7 +1449,7 @@ static int __init dw_probe(struct platform_device *pdev) | |||
1449 | struct dw_dma_chan *dwc = &dw->chan[i]; | 1449 | struct dw_dma_chan *dwc = &dw->chan[i]; |
1450 | 1450 | ||
1451 | dwc->chan.device = &dw->dma; | 1451 | dwc->chan.device = &dw->dma; |
1452 | dwc->chan.cookie = dwc->chan.completed_cookie = 1; | 1452 | dma_cookie_init(&dwc->chan); |
1453 | if (pdata->chan_allocation_order == CHAN_ALLOCATION_ASCENDING) | 1453 | if (pdata->chan_allocation_order == CHAN_ALLOCATION_ASCENDING) |
1454 | list_add_tail(&dwc->chan.device_node, | 1454 | list_add_tail(&dwc->chan.device_node, |
1455 | &dw->dma.channels); | 1455 | &dw->dma.channels); |
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index 142ebf0cd316..f25e83bf5678 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c | |||
@@ -854,8 +854,7 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan) | |||
854 | goto fail_clk_disable; | 854 | goto fail_clk_disable; |
855 | 855 | ||
856 | spin_lock_irq(&edmac->lock); | 856 | spin_lock_irq(&edmac->lock); |
857 | edmac->chan.completed_cookie = 1; | 857 | dma_cookie_init(&edmac->chan); |
858 | edmac->chan.cookie = 1; | ||
859 | ret = edmac->edma->hw_setup(edmac); | 858 | ret = edmac->edma->hw_setup(edmac); |
860 | spin_unlock_irq(&edmac->lock); | 859 | spin_unlock_irq(&edmac->lock); |
861 | 860 | ||
diff --git a/drivers/dma/intel_mid_dma.c b/drivers/dma/intel_mid_dma.c index c9ab4ac18e41..d599d96a57b6 100644 --- a/drivers/dma/intel_mid_dma.c +++ b/drivers/dma/intel_mid_dma.c | |||
@@ -867,7 +867,7 @@ static int intel_mid_dma_alloc_chan_resources(struct dma_chan *chan) | |||
867 | pm_runtime_put(&mid->pdev->dev); | 867 | pm_runtime_put(&mid->pdev->dev); |
868 | return -EIO; | 868 | return -EIO; |
869 | } | 869 | } |
870 | chan->completed_cookie = chan->cookie = 1; | 870 | dma_cookie_init(chan); |
871 | 871 | ||
872 | spin_lock_bh(&midc->lock); | 872 | spin_lock_bh(&midc->lock); |
873 | while (midc->descs_allocated < DESCS_PER_CHANNEL) { | 873 | while (midc->descs_allocated < DESCS_PER_CHANNEL) { |
@@ -1100,7 +1100,7 @@ static int mid_setup_dma(struct pci_dev *pdev) | |||
1100 | struct intel_mid_dma_chan *midch = &dma->ch[i]; | 1100 | struct intel_mid_dma_chan *midch = &dma->ch[i]; |
1101 | 1101 | ||
1102 | midch->chan.device = &dma->common; | 1102 | midch->chan.device = &dma->common; |
1103 | midch->chan.cookie = 1; | 1103 | dma_cookie_init(&midch->chan); |
1104 | midch->ch_id = dma->chan_base + i; | 1104 | midch->ch_id = dma->chan_base + i; |
1105 | pr_debug("MDMA:Init CH %d, ID %d\n", i, midch->ch_id); | 1105 | pr_debug("MDMA:Init CH %d, ID %d\n", i, midch->ch_id); |
1106 | 1106 | ||
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index bff9250a59ce..1880274b0850 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c | |||
@@ -1504,8 +1504,7 @@ static int idmac_alloc_chan_resources(struct dma_chan *chan) | |||
1504 | BUG_ON(chan->client_count > 1); | 1504 | BUG_ON(chan->client_count > 1); |
1505 | WARN_ON(ichan->status != IPU_CHANNEL_FREE); | 1505 | WARN_ON(ichan->status != IPU_CHANNEL_FREE); |
1506 | 1506 | ||
1507 | chan->cookie = 1; | 1507 | dma_cookie_init(chan); |
1508 | chan->completed_cookie = -ENXIO; | ||
1509 | 1508 | ||
1510 | ret = ipu_irq_map(chan->chan_id); | 1509 | ret = ipu_irq_map(chan->chan_id); |
1511 | if (ret < 0) | 1510 | if (ret < 0) |
@@ -1633,8 +1632,7 @@ static int __init ipu_idmac_init(struct ipu *ipu) | |||
1633 | snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i); | 1632 | snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i); |
1634 | 1633 | ||
1635 | dma_chan->device = &idmac->dma; | 1634 | dma_chan->device = &idmac->dma; |
1636 | dma_chan->cookie = 1; | 1635 | dma_cookie_init(dma_chan); |
1637 | dma_chan->completed_cookie = -ENXIO; | ||
1638 | dma_chan->chan_id = i; | 1636 | dma_chan->chan_id = i; |
1639 | list_add_tail(&dma_chan->device_node, &dma->channels); | 1637 | list_add_tail(&dma_chan->device_node, &dma->channels); |
1640 | } | 1638 | } |
diff --git a/drivers/dma/mpc512x_dma.c b/drivers/dma/mpc512x_dma.c index 138271591ae9..2ab0a3d0eed5 100644 --- a/drivers/dma/mpc512x_dma.c +++ b/drivers/dma/mpc512x_dma.c | |||
@@ -733,8 +733,7 @@ static int __devinit mpc_dma_probe(struct platform_device *op) | |||
733 | mchan = &mdma->channels[i]; | 733 | mchan = &mdma->channels[i]; |
734 | 734 | ||
735 | mchan->chan.device = dma; | 735 | mchan->chan.device = dma; |
736 | mchan->chan.cookie = 1; | 736 | dma_cookie_init(&mchan->chan); |
737 | mchan->chan.completed_cookie = mchan->chan.cookie; | ||
738 | 737 | ||
739 | INIT_LIST_HEAD(&mchan->free); | 738 | INIT_LIST_HEAD(&mchan->free); |
740 | INIT_LIST_HEAD(&mchan->prepared); | 739 | INIT_LIST_HEAD(&mchan->prepared); |
diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c index c30f63ee32c5..c93bb0459972 100644 --- a/drivers/dma/pch_dma.c +++ b/drivers/dma/pch_dma.c | |||
@@ -531,7 +531,7 @@ static int pd_alloc_chan_resources(struct dma_chan *chan) | |||
531 | spin_lock_irq(&pd_chan->lock); | 531 | spin_lock_irq(&pd_chan->lock); |
532 | list_splice(&tmp_list, &pd_chan->free_list); | 532 | list_splice(&tmp_list, &pd_chan->free_list); |
533 | pd_chan->descs_allocated = i; | 533 | pd_chan->descs_allocated = i; |
534 | chan->completed_cookie = chan->cookie = 1; | 534 | dma_cookie_init(chan); |
535 | spin_unlock_irq(&pd_chan->lock); | 535 | spin_unlock_irq(&pd_chan->lock); |
536 | 536 | ||
537 | pdc_enable_irq(chan, 1); | 537 | pdc_enable_irq(chan, 1); |
@@ -912,7 +912,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev, | |||
912 | struct pch_dma_chan *pd_chan = &pd->channels[i]; | 912 | struct pch_dma_chan *pd_chan = &pd->channels[i]; |
913 | 913 | ||
914 | pd_chan->chan.device = &pd->dma; | 914 | pd_chan->chan.device = &pd->dma; |
915 | pd_chan->chan.cookie = 1; | 915 | dma_cookie_init(&pd_chan->chan); |
916 | 916 | ||
917 | pd_chan->membase = ®s->desc[i]; | 917 | pd_chan->membase = ®s->desc[i]; |
918 | 918 | ||
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index d43019fc3496..7d6d7b416f68 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
@@ -304,7 +304,7 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan) | |||
304 | 304 | ||
305 | spin_lock_irqsave(&pch->lock, flags); | 305 | spin_lock_irqsave(&pch->lock, flags); |
306 | 306 | ||
307 | chan->completed_cookie = chan->cookie = 1; | 307 | dma_cookie_init(chan); |
308 | pch->cyclic = false; | 308 | pch->cyclic = false; |
309 | 309 | ||
310 | pch->pl330_chid = pl330_request_channel(&pdmac->pif); | 310 | pch->pl330_chid = pl330_request_channel(&pdmac->pif); |
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c index a760d981ece0..a2cde8585239 100644 --- a/drivers/dma/sirf-dma.c +++ b/drivers/dma/sirf-dma.c | |||
@@ -625,8 +625,7 @@ static int __devinit sirfsoc_dma_probe(struct platform_device *op) | |||
625 | schan = &sdma->channels[i]; | 625 | schan = &sdma->channels[i]; |
626 | 626 | ||
627 | schan->chan.device = dma; | 627 | schan->chan.device = dma; |
628 | schan->chan.cookie = 1; | 628 | dma_cookie_init(&schan->chan); |
629 | schan->chan.completed_cookie = schan->chan.cookie; | ||
630 | 629 | ||
631 | INIT_LIST_HEAD(&schan->free); | 630 | INIT_LIST_HEAD(&schan->free); |
632 | INIT_LIST_HEAD(&schan->prepared); | 631 | INIT_LIST_HEAD(&schan->prepared); |
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 07b82e367ffd..1ea6d02d08ab 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c | |||
@@ -2172,7 +2172,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) | |||
2172 | bool is_free_phy; | 2172 | bool is_free_phy; |
2173 | spin_lock_irqsave(&d40c->lock, flags); | 2173 | spin_lock_irqsave(&d40c->lock, flags); |
2174 | 2174 | ||
2175 | chan->completed_cookie = chan->cookie = 1; | 2175 | dma_cookie_init(chan); |
2176 | 2176 | ||
2177 | /* If no dma configuration is set use default configuration (memcpy) */ | 2177 | /* If no dma configuration is set use default configuration (memcpy) */ |
2178 | if (!d40c->configured) { | 2178 | if (!d40c->configured) { |
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c index 6383abbecce6..7805996661b8 100644 --- a/drivers/dma/timb_dma.c +++ b/drivers/dma/timb_dma.c | |||
@@ -477,8 +477,7 @@ static int td_alloc_chan_resources(struct dma_chan *chan) | |||
477 | } | 477 | } |
478 | 478 | ||
479 | spin_lock_bh(&td_chan->lock); | 479 | spin_lock_bh(&td_chan->lock); |
480 | chan->completed_cookie = 1; | 480 | dma_cookie_init(chan); |
481 | chan->cookie = 1; | ||
482 | spin_unlock_bh(&td_chan->lock); | 481 | spin_unlock_bh(&td_chan->lock); |
483 | 482 | ||
484 | return 0; | 483 | return 0; |
@@ -755,7 +754,7 @@ static int __devinit td_probe(struct platform_device *pdev) | |||
755 | } | 754 | } |
756 | 755 | ||
757 | td_chan->chan.device = &td->dma; | 756 | td_chan->chan.device = &td->dma; |
758 | td_chan->chan.cookie = 1; | 757 | dma_cookie_init(&td_chan->chan); |
759 | spin_lock_init(&td_chan->lock); | 758 | spin_lock_init(&td_chan->lock); |
760 | INIT_LIST_HEAD(&td_chan->active_list); | 759 | INIT_LIST_HEAD(&td_chan->active_list); |
761 | INIT_LIST_HEAD(&td_chan->queue); | 760 | INIT_LIST_HEAD(&td_chan->queue); |
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c index bb7b3d96ac6f..40440f946385 100644 --- a/drivers/dma/txx9dmac.c +++ b/drivers/dma/txx9dmac.c | |||
@@ -1034,7 +1034,7 @@ static int txx9dmac_alloc_chan_resources(struct dma_chan *chan) | |||
1034 | return -EIO; | 1034 | return -EIO; |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | chan->completed_cookie = chan->cookie = 1; | 1037 | dma_cookie_init(chan); |
1038 | 1038 | ||
1039 | dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE; | 1039 | dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE; |
1040 | txx9dmac_chan_set_SMPCHN(dc); | 1040 | txx9dmac_chan_set_SMPCHN(dc); |
@@ -1163,7 +1163,7 @@ static int __init txx9dmac_chan_probe(struct platform_device *pdev) | |||
1163 | dc->ddev->chan[ch] = dc; | 1163 | dc->ddev->chan[ch] = dc; |
1164 | dc->chan.device = &dc->dma; | 1164 | dc->chan.device = &dc->dma; |
1165 | list_add_tail(&dc->chan.device_node, &dc->chan.device->channels); | 1165 | list_add_tail(&dc->chan.device_node, &dc->chan.device->channels); |
1166 | dc->chan.cookie = dc->chan.completed_cookie = 1; | 1166 | dma_cookie_init(&dc->chan); |
1167 | 1167 | ||
1168 | if (is_dmac64(dc)) | 1168 | if (is_dmac64(dc)) |
1169 | dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch]; | 1169 | dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch]; |