]> Git Repo - linux.git/commitdiff
dmatest: properly handle duplicate DMA channels
authorTimur Tabi <[email protected]>
Fri, 19 Sep 2008 11:16:19 +0000 (04:16 -0700)
committerDan Williams <[email protected]>
Fri, 19 Sep 2008 11:16:19 +0000 (04:16 -0700)
Update the the dmatest driver so that it handles duplicate DMA channels
properly.

When a DMA client is notified of an available DMA channel, it must check if it
has already allocated resources for that channel.  If so, it should return
DMA_DUP.  This can happen, for example, if a DMA driver calls
dma_async_device_register() more than once.

Acked-by: Haavard Skinnemoen <[email protected]>
Signed-off-by: Timur Tabi <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
drivers/dma/dmatest.c

index a08d1970474362d7d8514ca3a74b8cbb2ffe6519..422500c6c1631114e1580dc53bfab449b08ebaf6 100644 (file)
@@ -325,6 +325,11 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan)
        struct dmatest_thread   *thread;
        unsigned int            i;
 
+       /* Have we already been told about this channel? */
+       list_for_each_entry(dtc, &dmatest_channels, node)
+               if (dtc->chan == chan)
+                       return DMA_DUP;
+
        dtc = kmalloc(sizeof(struct dmatest_chan), GFP_ATOMIC);
        if (!dtc) {
                pr_warning("dmatest: No memory for %s\n", chan->dev.bus_id);
This page took 0.05691 seconds and 4 git commands to generate.