提交 b6ad3981 编写于 作者: A Anson Huang 提交者: Eduardo Valentin

thermal: imx: handle error path in one place to save duplicated code

During probe phase, the error path can be handled in one place and
use goto method to save many duplicated code.
Signed-off-by: NAnson Huang <Anson.Huang@nxp.com>
Reviewed-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
上级 337a4aec
...@@ -762,9 +762,7 @@ static int imx_thermal_probe(struct platform_device *pdev) ...@@ -762,9 +762,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to get thermal clk: %d\n", ret); "failed to get thermal clk: %d\n", ret);
cpufreq_cooling_unregister(data->cdev); goto cpufreq_put;
cpufreq_cpu_put(data->policy);
return ret;
} }
/* /*
...@@ -777,9 +775,7 @@ static int imx_thermal_probe(struct platform_device *pdev) ...@@ -777,9 +775,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
ret = clk_prepare_enable(data->thermal_clk); ret = clk_prepare_enable(data->thermal_clk);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret); dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
cpufreq_cooling_unregister(data->cdev); goto cpufreq_put;
cpufreq_cpu_put(data->policy);
return ret;
} }
data->tz = thermal_zone_device_register("imx_thermal_zone", data->tz = thermal_zone_device_register("imx_thermal_zone",
...@@ -792,10 +788,7 @@ static int imx_thermal_probe(struct platform_device *pdev) ...@@ -792,10 +788,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
ret = PTR_ERR(data->tz); ret = PTR_ERR(data->tz);
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to register thermal zone device %d\n", ret); "failed to register thermal zone device %d\n", ret);
clk_disable_unprepare(data->thermal_clk); goto clk_disable;
cpufreq_cooling_unregister(data->cdev);
cpufreq_cpu_put(data->policy);
return ret;
} }
dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC" dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
...@@ -827,14 +820,20 @@ static int imx_thermal_probe(struct platform_device *pdev) ...@@ -827,14 +820,20 @@ static int imx_thermal_probe(struct platform_device *pdev)
0, "imx_thermal", data); 0, "imx_thermal", data);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret); dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret);
clk_disable_unprepare(data->thermal_clk); goto thermal_zone_unregister;
thermal_zone_device_unregister(data->tz);
cpufreq_cooling_unregister(data->cdev);
cpufreq_cpu_put(data->policy);
return ret;
} }
return 0; return 0;
thermal_zone_unregister:
thermal_zone_device_unregister(data->tz);
clk_disable:
clk_disable_unprepare(data->thermal_clk);
cpufreq_put:
cpufreq_cooling_unregister(data->cdev);
cpufreq_cpu_put(data->policy);
return ret;
} }
static int imx_thermal_remove(struct platform_device *pdev) static int imx_thermal_remove(struct platform_device *pdev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册