[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230403164610.3608082-2-void0red@hust.edu.cn>
Date: Tue, 4 Apr 2023 00:46:10 +0800
From: Kang Chen <void0red@...t.edu.cn>
To: daniel.lezcano@...aro.org
Cc: amitk@...nel.org, angelogioacchino.delregno@...labora.com,
bchihi@...libre.com, daniel@...rotopia.org, dzm91@...t.edu.cn,
error27@...il.com, henry.yen@...iatek.com,
hust-os-kernel-patches@...glegroups.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-mediatek@...ts.infradead.org, linux-pm@...r.kernel.org,
matthias.bgg@...il.com, rafael@...nel.org, rdunlap@...radead.org,
rui.zhang@...el.com, void0red@...il.com, void0red@...t.edu.cn
Subject: [PATCH v2 2/2] thermal: mediatek: change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe
use devm_clk_get_enabled to do automatic resource management.
Signed-off-by: Kang Chen <void0red@...t.edu.cn>
---
I'm not quite sure if this function should return 0 when
devm_thermal_add_hwmon_sysfs occurs error. So I keep it.
drivers/thermal/mediatek/auxadc_thermal.c | 25 ++++++++---------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/thermal/mediatek/auxadc_thermal.c b/drivers/thermal/mediatek/auxadc_thermal.c
index df5e2e354408..5baec2c08ebc 100644
--- a/drivers/thermal/mediatek/auxadc_thermal.c
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
@@ -1178,16 +1178,16 @@ static int mtk_thermal_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = clk_prepare_enable(mt->clk_auxadc);
- if (ret) {
+ ret = devm_clk_get_enabled(&pdev->dev, mt->clk_auxadc);
+ if (IS_ERR(ret)) {
dev_err(&pdev->dev, "Can't enable auxadc clk: %d\n", ret);
- return ret;
+ return PTR_ERR(ret);
}
- ret = clk_prepare_enable(mt->clk_peri_therm);
- if (ret) {
+ ret = devm_clk_get_enabled(&pdev->dev, mt->clk_peri_therm);
+ if (IS_ERR(ret)) {
dev_err(&pdev->dev, "Can't enable peri clk: %d\n", ret);
- goto err_disable_clk_auxadc;
+ return PTR_ERR(ret);
}
if (mt->conf->version != MTK_THERMAL_V1) {
@@ -1211,23 +1211,14 @@ static int mtk_thermal_probe(struct platform_device *pdev)
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
&mtk_thermal_ops);
- if (IS_ERR(tzdev)) {
- ret = PTR_ERR(tzdev);
- goto err_disable_clk_peri_therm;
- }
+ if (IS_ERR(tzdev))
+ return PTR_ERR(tzdev);
ret = devm_thermal_add_hwmon_sysfs(tzdev);
if (ret)
dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
return 0;
-
-err_disable_clk_peri_therm:
- clk_disable_unprepare(mt->clk_peri_therm);
-err_disable_clk_auxadc:
- clk_disable_unprepare(mt->clk_auxadc);
-
- return ret;
}
static int mtk_thermal_remove(struct platform_device *pdev)
--
2.34.1
Powered by blists - more mailing lists