Commit b93edcdd authored by Fabio Estevam's avatar Fabio Estevam Committed by Vinod Koul

dmaengine: imx-sdma: Check for clk_enable() errors

clk_enable() may fail, so we should better check the return value and
propagate it in the case of error.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent b096c137
...@@ -1093,16 +1093,20 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) ...@@ -1093,16 +1093,20 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
sdmac->event_id0 = data->dma_request; sdmac->event_id0 = data->dma_request;
sdmac->event_id1 = data->dma_request2; sdmac->event_id1 = data->dma_request2;
clk_enable(sdmac->sdma->clk_ipg); ret = clk_enable(sdmac->sdma->clk_ipg);
clk_enable(sdmac->sdma->clk_ahb); if (ret)
return ret;
ret = clk_enable(sdmac->sdma->clk_ahb);
if (ret)
goto disable_clk_ipg;
ret = sdma_request_channel(sdmac); ret = sdma_request_channel(sdmac);
if (ret) if (ret)
return ret; goto disable_clk_ahb;
ret = sdma_set_channel_priority(sdmac, prio); ret = sdma_set_channel_priority(sdmac, prio);
if (ret) if (ret)
return ret; goto disable_clk_ahb;
dma_async_tx_descriptor_init(&sdmac->desc, chan); dma_async_tx_descriptor_init(&sdmac->desc, chan);
sdmac->desc.tx_submit = sdma_tx_submit; sdmac->desc.tx_submit = sdma_tx_submit;
...@@ -1110,6 +1114,12 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) ...@@ -1110,6 +1114,12 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
sdmac->desc.flags = DMA_CTRL_ACK; sdmac->desc.flags = DMA_CTRL_ACK;
return 0; return 0;
disable_clk_ahb:
clk_disable(sdmac->sdma->clk_ahb);
disable_clk_ipg:
clk_disable(sdmac->sdma->clk_ipg);
return ret;
} }
static void sdma_free_chan_resources(struct dma_chan *chan) static void sdma_free_chan_resources(struct dma_chan *chan)
...@@ -1533,8 +1543,12 @@ static int sdma_init(struct sdma_engine *sdma) ...@@ -1533,8 +1543,12 @@ static int sdma_init(struct sdma_engine *sdma)
int i, ret; int i, ret;
dma_addr_t ccb_phys; dma_addr_t ccb_phys;
clk_enable(sdma->clk_ipg); ret = clk_enable(sdma->clk_ipg);
clk_enable(sdma->clk_ahb); if (ret)
return ret;
ret = clk_enable(sdma->clk_ahb);
if (ret)
goto disable_clk_ipg;
/* Be sure SDMA has not started yet */ /* Be sure SDMA has not started yet */
writel_relaxed(0, sdma->regs + SDMA_H_C0PTR); writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
...@@ -1590,8 +1604,9 @@ static int sdma_init(struct sdma_engine *sdma) ...@@ -1590,8 +1604,9 @@ static int sdma_init(struct sdma_engine *sdma)
return 0; return 0;
err_dma_alloc: err_dma_alloc:
clk_disable(sdma->clk_ipg);
clk_disable(sdma->clk_ahb); clk_disable(sdma->clk_ahb);
disable_clk_ipg:
clk_disable(sdma->clk_ipg);
dev_err(sdma->dev, "initialisation failed with %d\n", ret); dev_err(sdma->dev, "initialisation failed with %d\n", ret);
return ret; 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