Skip to content

Commit

Permalink
dmatest: properly handle duplicate DMA channels
Browse files Browse the repository at this point in the history
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 <haavard.skinnemoen@atmel.com>
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Timur Tabi authored and Dan Williams committed Sep 19, 2008
1 parent 89f72a0 commit 6b31419
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/dma/dmatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6b31419

Please sign in to comment.