Commit 05f4fae9 authored by Dongliang Mu's avatar Dongliang Mu Committed by Vinod Koul

dmaengine: rcar-dmac: refactor the error handling code of rcar_dmac_probe

In rcar_dmac_probe, if pm_runtime_resume_and_get fails, it forgets to
disable runtime PM. And of_dma_controller_free should only be invoked
after the success of of_dma_controller_register.

Fix this by refactoring the error handling code.
Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20211020143546.3436205-1-mudongliangabcd@gmail.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent e7e1e880
...@@ -1916,7 +1916,7 @@ static int rcar_dmac_probe(struct platform_device *pdev) ...@@ -1916,7 +1916,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
ret = pm_runtime_resume_and_get(&pdev->dev); ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "runtime PM get sync failed (%d)\n", ret); dev_err(&pdev->dev, "runtime PM get sync failed (%d)\n", ret);
return ret; goto err_pm_disable;
} }
ret = rcar_dmac_init(dmac); ret = rcar_dmac_init(dmac);
...@@ -1924,7 +1924,7 @@ static int rcar_dmac_probe(struct platform_device *pdev) ...@@ -1924,7 +1924,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to reset device\n"); dev_err(&pdev->dev, "failed to reset device\n");
goto error; goto err_pm_disable;
} }
/* Initialize engine */ /* Initialize engine */
...@@ -1958,14 +1958,14 @@ static int rcar_dmac_probe(struct platform_device *pdev) ...@@ -1958,14 +1958,14 @@ static int rcar_dmac_probe(struct platform_device *pdev)
for_each_rcar_dmac_chan(i, dmac, chan) { for_each_rcar_dmac_chan(i, dmac, chan) {
ret = rcar_dmac_chan_probe(dmac, chan); ret = rcar_dmac_chan_probe(dmac, chan);
if (ret < 0) if (ret < 0)
goto error; goto err_pm_disable;
} }
/* Register the DMAC as a DMA provider for DT. */ /* Register the DMAC as a DMA provider for DT. */
ret = of_dma_controller_register(pdev->dev.of_node, rcar_dmac_of_xlate, ret = of_dma_controller_register(pdev->dev.of_node, rcar_dmac_of_xlate,
NULL); NULL);
if (ret < 0) if (ret < 0)
goto error; goto err_pm_disable;
/* /*
* Register the DMA engine device. * Register the DMA engine device.
...@@ -1974,12 +1974,13 @@ static int rcar_dmac_probe(struct platform_device *pdev) ...@@ -1974,12 +1974,13 @@ static int rcar_dmac_probe(struct platform_device *pdev)
*/ */
ret = dma_async_device_register(engine); ret = dma_async_device_register(engine);
if (ret < 0) if (ret < 0)
goto error; goto err_dma_free;
return 0; return 0;
error: err_dma_free:
of_dma_controller_free(pdev->dev.of_node); of_dma_controller_free(pdev->dev.of_node);
err_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
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