Skip to content

Commit a3e9a9a

Browse files
Kang Chendlezcano
authored andcommitted
thermal/drivers/mediatek: Change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe
Use devm_clk_get_enabled to do automatic resource management. Meanwhile, remove error handling labels in the probe function and the whole remove function. Signed-off-by: Kang Chen <void0red@hust.edu.cn> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230419020749.621257-2-void0red@hust.edu.cn
1 parent f05c7b7 commit a3e9a9a

1 file changed

Lines changed: 9 additions & 35 deletions

File tree

drivers/thermal/mediatek/auxadc_thermal.c

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,14 +1206,6 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12061206

12071207
mt->conf = of_device_get_match_data(&pdev->dev);
12081208

1209-
mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm");
1210-
if (IS_ERR(mt->clk_peri_therm))
1211-
return PTR_ERR(mt->clk_peri_therm);
1212-
1213-
mt->clk_auxadc = devm_clk_get(&pdev->dev, "auxadc");
1214-
if (IS_ERR(mt->clk_auxadc))
1215-
return PTR_ERR(mt->clk_auxadc);
1216-
12171209
mt->thermal_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
12181210
if (IS_ERR(mt->thermal_base))
12191211
return PTR_ERR(mt->thermal_base);
@@ -1272,16 +1264,18 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12721264
if (ret)
12731265
return ret;
12741266

1275-
ret = clk_prepare_enable(mt->clk_auxadc);
1276-
if (ret) {
1267+
mt->clk_auxadc = devm_clk_get_enabled(&pdev->dev, "auxadc");
1268+
if (IS_ERR(mt->clk_auxadc)) {
1269+
ret = PTR_ERR(mt->clk_auxadc);
12771270
dev_err(&pdev->dev, "Can't enable auxadc clk: %d\n", ret);
12781271
return ret;
12791272
}
12801273

1281-
ret = clk_prepare_enable(mt->clk_peri_therm);
1282-
if (ret) {
1274+
mt->clk_peri_therm = devm_clk_get_enabled(&pdev->dev, "therm");
1275+
if (IS_ERR(mt->clk_peri_therm)) {
1276+
ret = PTR_ERR(mt->clk_peri_therm);
12831277
dev_err(&pdev->dev, "Can't enable peri clk: %d\n", ret);
1284-
goto err_disable_clk_auxadc;
1278+
return ret;
12851279
}
12861280

12871281
mtk_thermal_turn_on_buffer(mt, apmixed_base);
@@ -1305,38 +1299,18 @@ static int mtk_thermal_probe(struct platform_device *pdev)
13051299

13061300
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
13071301
&mtk_thermal_ops);
1308-
if (IS_ERR(tzdev)) {
1309-
ret = PTR_ERR(tzdev);
1310-
goto err_disable_clk_peri_therm;
1311-
}
1302+
if (IS_ERR(tzdev))
1303+
return PTR_ERR(tzdev);
13121304

13131305
ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
13141306
if (ret)
13151307
dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
13161308

13171309
return 0;
1318-
1319-
err_disable_clk_peri_therm:
1320-
clk_disable_unprepare(mt->clk_peri_therm);
1321-
err_disable_clk_auxadc:
1322-
clk_disable_unprepare(mt->clk_auxadc);
1323-
1324-
return ret;
1325-
}
1326-
1327-
static int mtk_thermal_remove(struct platform_device *pdev)
1328-
{
1329-
struct mtk_thermal *mt = platform_get_drvdata(pdev);
1330-
1331-
clk_disable_unprepare(mt->clk_peri_therm);
1332-
clk_disable_unprepare(mt->clk_auxadc);
1333-
1334-
return 0;
13351310
}
13361311

13371312
static struct platform_driver mtk_thermal_driver = {
13381313
.probe = mtk_thermal_probe,
1339-
.remove = mtk_thermal_remove,
13401314
.driver = {
13411315
.name = "mtk-thermal",
13421316
.of_match_table = mtk_thermal_of_match,

0 commit comments

Comments
 (0)