Commit 83515bc7 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Paul Mundt

SH: fix error paths in DMA driver

If channel allocation is failing, mark the channel unused and give PM a chance
to power down the hardware.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent e3a4317e
...@@ -290,6 +290,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) ...@@ -290,6 +290,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
struct sh_dmae_chan *sh_chan = to_sh_chan(chan); struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
struct sh_desc *desc; struct sh_desc *desc;
struct sh_dmae_slave *param = chan->private; struct sh_dmae_slave *param = chan->private;
int ret;
pm_runtime_get_sync(sh_chan->dev); pm_runtime_get_sync(sh_chan->dev);
...@@ -301,11 +302,15 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) ...@@ -301,11 +302,15 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
struct sh_dmae_slave_config *cfg; struct sh_dmae_slave_config *cfg;
cfg = sh_dmae_find_slave(sh_chan, param->slave_id); cfg = sh_dmae_find_slave(sh_chan, param->slave_id);
if (!cfg) if (!cfg) {
return -EINVAL; ret = -EINVAL;
goto efindslave;
}
if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) {
return -EBUSY; ret = -EBUSY;
goto etestused;
}
param->config = cfg; param->config = cfg;
...@@ -334,10 +339,20 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) ...@@ -334,10 +339,20 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
} }
spin_unlock_bh(&sh_chan->desc_lock); spin_unlock_bh(&sh_chan->desc_lock);
if (!sh_chan->descs_allocated) if (!sh_chan->descs_allocated) {
pm_runtime_put(sh_chan->dev); ret = -ENOMEM;
goto edescalloc;
}
return sh_chan->descs_allocated; 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;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment