linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SH: fix error paths in DMA driver
@ 2010-04-19  8:39 Guennadi Liakhovetski
  2010-04-26  7:09 ` Paul Mundt
  0 siblings, 1 reply; 2+ messages in thread
From: Guennadi Liakhovetski @ 2010-04-19  8:39 UTC (permalink / raw)
  To: linux-sh

If channel allocation is failing, mark the channel unused and give PM a chance
to power down the hardware.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

2.6.34?

 drivers/dma/shdma.c |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index bbc3dfe..549bae9 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -288,6 +288,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
 	struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
 	struct sh_desc *desc;
 	struct sh_dmae_slave *param = chan->private;
+	int ret;
 
 	pm_runtime_get_sync(sh_chan->dev);
 
@@ -299,11 +300,15 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
 		struct sh_dmae_slave_config *cfg;
 
 		cfg = sh_dmae_find_slave(sh_chan, param);
-		if (!cfg)
-			return -EINVAL;
+		if (!cfg) {
+			ret = -EINVAL;
+			goto efindslave;
+		}
 
-		if (test_and_set_bit(param->slave_id, sh_dmae_slave_used))
-			return -EBUSY;
+		if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) {
+			ret = -EBUSY;
+			goto etestused;
+		}
 
 		param->config = cfg;
 
@@ -332,10 +337,20 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
 	}
 	spin_unlock_bh(&sh_chan->desc_lock);
 
-	if (!sh_chan->descs_allocated)
-		pm_runtime_put(sh_chan->dev);
+	if (!sh_chan->descs_allocated) {
+		ret = -ENOMEM;
+		goto edescalloc;
+	}
 
 	return sh_chan->descs_allocated;
+
+edescalloc:
+	if (param)
+		clear_bit(param->slave_id, sh_dmae_slave_used);
+etestused:
+efindslave:
+	pm_runtime_put(sh_chan->dev);
+	return ret;
 }
 
 /*
-- 
1.6.2.4


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

* Re: [PATCH] SH: fix error paths in DMA driver
  2010-04-19  8:39 [PATCH] SH: fix error paths in DMA driver Guennadi Liakhovetski
@ 2010-04-26  7:09 ` Paul Mundt
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Mundt @ 2010-04-26  7:09 UTC (permalink / raw)
  To: linux-sh

On Mon, Apr 19, 2010 at 10:39:39AM +0200, Guennadi Liakhovetski wrote:
> If channel allocation is failing, mark the channel unused and give PM a chance
> to power down the hardware.

On Wed, Apr 21, 2010 at 05:14:19PM +0200, Guennadi Liakhovetski wrote:
> CHCR_TS_HIGH_SHIFT is defined as a shift of TS high bits in CHCR register,
> relative to low bits. The TS_INDEX2VAL() macro has to take this into account.

Both applied for 2.6.34, thanks.

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

end of thread, other threads:[~2010-04-26  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-19  8:39 [PATCH] SH: fix error paths in DMA driver Guennadi Liakhovetski
2010-04-26  7:09 ` Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).