Commit c75ed9f5 authored by Biju Das's avatar Biju Das Committed by Mark Brown

ASoC: sh: rz-ssi: Improve error handling in rz_ssi_probe() error path

We usually do cleanup in reverse order of init. Currently in case of
error rz_ssi_release_dma_channels() done in the reverse order. This
patch improves error handling in rz_ssi_probe() error path.

While at it, use "goto cleanup" style to reduce code duplication.
Reported-by: default avatarPavel Machek <pavel@denx.de>
Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20220728092612.38858-1-biju.das.jz@bp.renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c0fc96fe
...@@ -1017,32 +1017,36 @@ static int rz_ssi_probe(struct platform_device *pdev) ...@@ -1017,32 +1017,36 @@ static int rz_ssi_probe(struct platform_device *pdev)
ssi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); ssi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(ssi->rstc)) { if (IS_ERR(ssi->rstc)) {
rz_ssi_release_dma_channels(ssi); ret = PTR_ERR(ssi->rstc);
return PTR_ERR(ssi->rstc); goto err_reset;
} }
reset_control_deassert(ssi->rstc); reset_control_deassert(ssi->rstc);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
ret = pm_runtime_resume_and_get(&pdev->dev); ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret < 0) { if (ret < 0) {
rz_ssi_release_dma_channels(ssi); dev_err(&pdev->dev, "pm_runtime_resume_and_get failed\n");
pm_runtime_disable(ssi->dev); goto err_pm;
reset_control_assert(ssi->rstc);
return dev_err_probe(ssi->dev, ret, "pm_runtime_resume_and_get failed\n");
} }
ret = devm_snd_soc_register_component(&pdev->dev, &rz_ssi_soc_component, ret = devm_snd_soc_register_component(&pdev->dev, &rz_ssi_soc_component,
rz_ssi_soc_dai, rz_ssi_soc_dai,
ARRAY_SIZE(rz_ssi_soc_dai)); ARRAY_SIZE(rz_ssi_soc_dai));
if (ret < 0) { if (ret < 0) {
rz_ssi_release_dma_channels(ssi);
pm_runtime_put(ssi->dev);
pm_runtime_disable(ssi->dev);
reset_control_assert(ssi->rstc);
dev_err(&pdev->dev, "failed to register snd component\n"); dev_err(&pdev->dev, "failed to register snd component\n");
goto err_snd_soc;
} }
return 0;
err_snd_soc:
pm_runtime_put(ssi->dev);
err_pm:
pm_runtime_disable(ssi->dev);
reset_control_assert(ssi->rstc);
err_reset:
rz_ssi_release_dma_channels(ssi);
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