Skip to content

Commit d3ee98c

Browse files
Russell King - ARM LinuxVinod Koul
authored andcommitted
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>
1 parent 96a2af4 commit d3ee98c

15 files changed

Lines changed: 31 additions & 28 deletions

‎drivers/dma/amba-pl08x.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,8 +1709,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x,
17091709
chan->name);
17101710

17111711
chan->chan.device = dmadev;
1712-
chan->chan.cookie = 0;
1713-
chan->chan.completed_cookie = 0;
1712+
dma_cookie_init(&chan->chan);
17141713

17151714
spin_lock_init(&chan->lock);
17161715
INIT_LIST_HEAD(&chan->pend_list);

‎drivers/dma/at_hdmac.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan)
11031103
spin_lock_irqsave(&atchan->lock, flags);
11041104
atchan->descs_allocated = i;
11051105
list_splice(&tmp_list, &atchan->free_list);
1106-
chan->completed_cookie = chan->cookie = 1;
1106+
dma_cookie_init(chan);
11071107
spin_unlock_irqrestore(&atchan->lock, flags);
11081108

11091109
/* channel parameters */
@@ -1303,7 +1303,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
13031303
struct at_dma_chan *atchan = &atdma->chan[i];
13041304

13051305
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);
13071307
list_add_tail(&atchan->chan_common.device_node,
13081308
&atdma->dma_common.channels);
13091309

‎drivers/dma/coh901318.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ static int coh901318_alloc_chan_resources(struct dma_chan *chan)
915915
coh901318_config(cohc, NULL);
916916

917917
cohc->allocated = 1;
918-
chan->completed_cookie = chan->cookie = 1;
918+
dma_cookie_init(chan);
919919

920920
spin_unlock_irqrestore(&cohc->lock, flags);
921921

‎drivers/dma/dmaengine.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
#include <linux/bug.h>
99
#include <linux/dmaengine.h>
1010

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+
1121
/**
1222
* dma_cookie_assign - assign a DMA engine cookie to the descriptor
1323
* @tx: descriptor needing cookie

‎drivers/dma/dw_dmac.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan)
10211021
return -EIO;
10221022
}
10231023

1024-
chan->completed_cookie = chan->cookie = 1;
1024+
dma_cookie_init(chan);
10251025

10261026
/*
10271027
* NOTE: some controllers may have additional features that we
@@ -1449,7 +1449,7 @@ static int __init dw_probe(struct platform_device *pdev)
14491449
struct dw_dma_chan *dwc = &dw->chan[i];
14501450

14511451
dwc->chan.device = &dw->dma;
1452-
dwc->chan.cookie = dwc->chan.completed_cookie = 1;
1452+
dma_cookie_init(&dwc->chan);
14531453
if (pdata->chan_allocation_order == CHAN_ALLOCATION_ASCENDING)
14541454
list_add_tail(&dwc->chan.device_node,
14551455
&dw->dma.channels);

‎drivers/dma/ep93xx_dma.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,7 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
854854
goto fail_clk_disable;
855855

856856
spin_lock_irq(&edmac->lock);
857-
edmac->chan.completed_cookie = 1;
858-
edmac->chan.cookie = 1;
857+
dma_cookie_init(&edmac->chan);
859858
ret = edmac->edma->hw_setup(edmac);
860859
spin_unlock_irq(&edmac->lock);
861860

‎drivers/dma/intel_mid_dma.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ static int intel_mid_dma_alloc_chan_resources(struct dma_chan *chan)
867867
pm_runtime_put(&mid->pdev->dev);
868868
return -EIO;
869869
}
870-
chan->completed_cookie = chan->cookie = 1;
870+
dma_cookie_init(chan);
871871

872872
spin_lock_bh(&midc->lock);
873873
while (midc->descs_allocated < DESCS_PER_CHANNEL) {
@@ -1100,7 +1100,7 @@ static int mid_setup_dma(struct pci_dev *pdev)
11001100
struct intel_mid_dma_chan *midch = &dma->ch[i];
11011101

11021102
midch->chan.device = &dma->common;
1103-
midch->chan.cookie = 1;
1103+
dma_cookie_init(&midch->chan);
11041104
midch->ch_id = dma->chan_base + i;
11051105
pr_debug("MDMA:Init CH %d, ID %d\n", i, midch->ch_id);
11061106

‎drivers/dma/ipu/ipu_idmac.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,7 @@ static int idmac_alloc_chan_resources(struct dma_chan *chan)
15041504
BUG_ON(chan->client_count > 1);
15051505
WARN_ON(ichan->status != IPU_CHANNEL_FREE);
15061506

1507-
chan->cookie = 1;
1508-
chan->completed_cookie = -ENXIO;
1507+
dma_cookie_init(chan);
15091508

15101509
ret = ipu_irq_map(chan->chan_id);
15111510
if (ret < 0)
@@ -1633,8 +1632,7 @@ static int __init ipu_idmac_init(struct ipu *ipu)
16331632
snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i);
16341633

16351634
dma_chan->device = &idmac->dma;
1636-
dma_chan->cookie = 1;
1637-
dma_chan->completed_cookie = -ENXIO;
1635+
dma_cookie_init(dma_chan);
16381636
dma_chan->chan_id = i;
16391637
list_add_tail(&dma_chan->device_node, &dma->channels);
16401638
}

‎drivers/dma/mpc512x_dma.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,7 @@ static int __devinit mpc_dma_probe(struct platform_device *op)
733733
mchan = &mdma->channels[i];
734734

735735
mchan->chan.device = dma;
736-
mchan->chan.cookie = 1;
737-
mchan->chan.completed_cookie = mchan->chan.cookie;
736+
dma_cookie_init(&mchan->chan);
738737

739738
INIT_LIST_HEAD(&mchan->free);
740739
INIT_LIST_HEAD(&mchan->prepared);

‎drivers/dma/pch_dma.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static int pd_alloc_chan_resources(struct dma_chan *chan)
531531
spin_lock_irq(&pd_chan->lock);
532532
list_splice(&tmp_list, &pd_chan->free_list);
533533
pd_chan->descs_allocated = i;
534-
chan->completed_cookie = chan->cookie = 1;
534+
dma_cookie_init(chan);
535535
spin_unlock_irq(&pd_chan->lock);
536536

537537
pdc_enable_irq(chan, 1);
@@ -912,7 +912,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev,
912912
struct pch_dma_chan *pd_chan = &pd->channels[i];
913913

914914
pd_chan->chan.device = &pd->dma;
915-
pd_chan->chan.cookie = 1;
915+
dma_cookie_init(&pd_chan->chan);
916916

917917
pd_chan->membase = &regs->desc[i];
918918

0 commit comments

Comments
 (0)