Commit ff0b12ba authored by Jonas Aaberg's avatar Jonas Aaberg Committed by Dan Williams

DMAENGINE: ste_dma40: improve allocation error handling

Better error handling when channel allocation fails.
Signed-off-by: default avatarJonas Aaberg <jonas.aberg@stericsson.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@stericsson.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent c675b1b4
...@@ -1239,7 +1239,7 @@ static int d40_free_dma(struct d40_chan *d40c) ...@@ -1239,7 +1239,7 @@ static int d40_free_dma(struct d40_chan *d40c)
res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ); res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ);
if (res) { if (res) {
dev_err(&d40c->chan.dev->device, "[%s] suspend\n", dev_err(&d40c->chan.dev->device, "[%s] suspend failed\n",
__func__); __func__);
return res; return res;
} }
...@@ -1657,8 +1657,12 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) ...@@ -1657,8 +1657,12 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
*/ */
if (d40c->dma_cfg.channel_type == 0) { if (d40c->dma_cfg.channel_type == 0) {
err = d40_config_memcpy(d40c); err = d40_config_memcpy(d40c);
if (err) if (err) {
goto err_alloc; dev_err(&d40c->chan.dev->device,
"[%s] Failed to configure memcpy channel\n",
__func__);
goto fail;
}
} }
is_free_phy = (d40c->phy_chan == NULL); is_free_phy = (d40c->phy_chan == NULL);
...@@ -1666,7 +1670,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) ...@@ -1666,7 +1670,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
if (err) { if (err) {
dev_err(&d40c->chan.dev->device, dev_err(&d40c->chan.dev->device,
"[%s] Failed to allocate channel\n", __func__); "[%s] Failed to allocate channel\n", __func__);
goto err_alloc; goto fail;
} }
/* Fill in basic CFG register values */ /* Fill in basic CFG register values */
...@@ -1699,17 +1703,9 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) ...@@ -1699,17 +1703,9 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
__func__); __func__);
} }
} }
fail:
spin_unlock_irqrestore(&d40c->lock, flags); spin_unlock_irqrestore(&d40c->lock, flags);
return 0; return err;
err_config:
(void) d40_free_dma(d40c);
err_alloc:
spin_unlock_irqrestore(&d40c->lock, flags);
dev_err(&d40c->chan.dev->device,
"[%s] Channel allocation failed\n", __func__);
return -EINVAL;
} }
static void d40_free_chan_resources(struct dma_chan *chan) static void d40_free_chan_resources(struct dma_chan *chan)
......
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