dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove()
We usually do cleanup in reverse order of init. Currently, in the case of error, this is not followed in rz_dmac_probe(), and similar case for remove(). This patch improves error handling in probe() and cleanup in reverse order of init in the remove(). Reported-by: Pavel Machek <pavel@denx.de> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Pavel Machek <pavel@denx.de> Link: https://lore.kernel.org/r/20230706112150.198941-2-biju.das.jz@bp.renesas.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
06c2afb862
commit
7ab04b7cff
|
@ -947,7 +947,6 @@ static int rz_dmac_probe(struct platform_device *pdev)
|
||||||
dma_register_err:
|
dma_register_err:
|
||||||
of_dma_controller_free(pdev->dev.of_node);
|
of_dma_controller_free(pdev->dev.of_node);
|
||||||
err:
|
err:
|
||||||
reset_control_assert(dmac->rstc);
|
|
||||||
channel_num = i ? i - 1 : 0;
|
channel_num = i ? i - 1 : 0;
|
||||||
for (i = 0; i < channel_num; i++) {
|
for (i = 0; i < channel_num; i++) {
|
||||||
struct rz_dmac_chan *channel = &dmac->channels[i];
|
struct rz_dmac_chan *channel = &dmac->channels[i];
|
||||||
|
@ -958,6 +957,7 @@ err:
|
||||||
channel->lmdesc.base_dma);
|
channel->lmdesc.base_dma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_control_assert(dmac->rstc);
|
||||||
err_pm_runtime_put:
|
err_pm_runtime_put:
|
||||||
pm_runtime_put(&pdev->dev);
|
pm_runtime_put(&pdev->dev);
|
||||||
err_pm_disable:
|
err_pm_disable:
|
||||||
|
@ -971,6 +971,8 @@ static int rz_dmac_remove(struct platform_device *pdev)
|
||||||
struct rz_dmac *dmac = platform_get_drvdata(pdev);
|
struct rz_dmac *dmac = platform_get_drvdata(pdev);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
dma_async_device_unregister(&dmac->engine);
|
||||||
|
of_dma_controller_free(pdev->dev.of_node);
|
||||||
for (i = 0; i < dmac->n_channels; i++) {
|
for (i = 0; i < dmac->n_channels; i++) {
|
||||||
struct rz_dmac_chan *channel = &dmac->channels[i];
|
struct rz_dmac_chan *channel = &dmac->channels[i];
|
||||||
|
|
||||||
|
@ -979,8 +981,6 @@ static int rz_dmac_remove(struct platform_device *pdev)
|
||||||
channel->lmdesc.base,
|
channel->lmdesc.base,
|
||||||
channel->lmdesc.base_dma);
|
channel->lmdesc.base_dma);
|
||||||
}
|
}
|
||||||
of_dma_controller_free(pdev->dev.of_node);
|
|
||||||
dma_async_device_unregister(&dmac->engine);
|
|
||||||
reset_control_assert(dmac->rstc);
|
reset_control_assert(dmac->rstc);
|
||||||
pm_runtime_put(&pdev->dev);
|
pm_runtime_put(&pdev->dev);
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
|
|
Loading…
Reference in New Issue