public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmatest: properly handle duplicate DMA channels
@ 2008-09-18 15:21 Timur Tabi
  2008-09-18 15:32 ` Haavard Skinnemoen
  2008-09-19 23:31 ` Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Timur Tabi @ 2008-09-18 15:21 UTC (permalink / raw)
  To: dan.j.williams, haavard.skinnemoen, linux-kernel

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.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 drivers/dma/dmatest.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index a08d197..2689d90 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -321,10 +321,15 @@ static void dmatest_cleanup_channel(struct dmatest_chan *dtc)
 
 static enum dma_state_client dmatest_add_channel(struct dma_chan *chan)
 {
-	struct dmatest_chan	*dtc;
+	struct dmatest_chan	*dtc, *_dtc;
 	struct dmatest_thread	*thread;
 	unsigned int		i;
 
+	/* Have we already been told about this channel? */
+	list_for_each_entry_safe(dtc, _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);
-- 
1.5.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-09-20 22:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18 15:21 [PATCH] dmatest: properly handle duplicate DMA channels Timur Tabi
2008-09-18 15:32 ` Haavard Skinnemoen
2008-09-18 15:34   ` Timur Tabi
2008-09-18 15:48     ` Haavard Skinnemoen
2008-09-19 23:31 ` Andrew Morton
2008-09-20 12:42   ` Haavard Skinnemoen
2008-09-20 21:40   ` Dan Williams
2008-09-20 22:20     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox