Commit 91b5cfc0 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul

soundwire: qcom: fix error handling in probe

Make sure all error cases are properly handled and all resources freed.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200429185057.12810-1-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 611905d6
...@@ -765,12 +765,16 @@ static int qcom_swrm_probe(struct platform_device *pdev) ...@@ -765,12 +765,16 @@ static int qcom_swrm_probe(struct platform_device *pdev)
} }
ctrl->irq = of_irq_get(dev->of_node, 0); ctrl->irq = of_irq_get(dev->of_node, 0);
if (ctrl->irq < 0) if (ctrl->irq < 0) {
return ctrl->irq; ret = ctrl->irq;
goto err_init;
}
ctrl->hclk = devm_clk_get(dev, "iface"); ctrl->hclk = devm_clk_get(dev, "iface");
if (IS_ERR(ctrl->hclk)) if (IS_ERR(ctrl->hclk)) {
return PTR_ERR(ctrl->hclk); ret = PTR_ERR(ctrl->hclk);
goto err_init;
}
clk_prepare_enable(ctrl->hclk); clk_prepare_enable(ctrl->hclk);
...@@ -787,7 +791,7 @@ static int qcom_swrm_probe(struct platform_device *pdev) ...@@ -787,7 +791,7 @@ static int qcom_swrm_probe(struct platform_device *pdev)
ret = qcom_swrm_get_port_config(ctrl); ret = qcom_swrm_get_port_config(ctrl);
if (ret) if (ret)
return ret; goto err_clk;
params = &ctrl->bus.params; params = &ctrl->bus.params;
params->max_dr_freq = DEFAULT_CLK_FREQ; params->max_dr_freq = DEFAULT_CLK_FREQ;
...@@ -814,28 +818,32 @@ static int qcom_swrm_probe(struct platform_device *pdev) ...@@ -814,28 +818,32 @@ static int qcom_swrm_probe(struct platform_device *pdev)
"soundwire", ctrl); "soundwire", ctrl);
if (ret) { if (ret) {
dev_err(dev, "Failed to request soundwire irq\n"); dev_err(dev, "Failed to request soundwire irq\n");
goto err; goto err_clk;
} }
ret = sdw_add_bus_master(&ctrl->bus); ret = sdw_add_bus_master(&ctrl->bus);
if (ret) { if (ret) {
dev_err(dev, "Failed to register Soundwire controller (%d)\n", dev_err(dev, "Failed to register Soundwire controller (%d)\n",
ret); ret);
goto err; goto err_clk;
} }
qcom_swrm_init(ctrl); qcom_swrm_init(ctrl);
ret = qcom_swrm_register_dais(ctrl); ret = qcom_swrm_register_dais(ctrl);
if (ret) if (ret)
goto err; goto err_master_add;
dev_info(dev, "Qualcomm Soundwire controller v%x.%x.%x Registered\n", dev_info(dev, "Qualcomm Soundwire controller v%x.%x.%x Registered\n",
(ctrl->version >> 24) & 0xff, (ctrl->version >> 16) & 0xff, (ctrl->version >> 24) & 0xff, (ctrl->version >> 16) & 0xff,
ctrl->version & 0xffff); ctrl->version & 0xffff);
return 0; return 0;
err:
err_master_add:
sdw_delete_bus_master(&ctrl->bus);
err_clk:
clk_disable_unprepare(ctrl->hclk); clk_disable_unprepare(ctrl->hclk);
err_init:
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