1 From 227d1856924ec00a4f5bdf5afcf77bc7f3f04e86 Mon Sep 17 00:00:00 2001
2 From: Kang Chen <void0red@hust.edu.cn>
3 Date: Wed, 19 Apr 2023 10:07:49 +0800
4 Subject: [PATCH 19/42] thermal/drivers/mediatek: Change clk_prepare_enable to
5 devm_clk_get_enabled in mtk_thermal_probe
7 Use devm_clk_get_enabled to do automatic resource management.
8 Meanwhile, remove error handling labels in the probe function and
9 the whole remove function.
11 Signed-off-by: Kang Chen <void0red@hust.edu.cn>
12 Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
13 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
14 Link: https://lore.kernel.org/r/20230419020749.621257-2-void0red@hust.edu.cn
16 drivers/thermal/mediatek/auxadc_thermal.c | 44 +++++------------------
17 1 file changed, 9 insertions(+), 35 deletions(-)
19 --- a/drivers/thermal/mediatek/auxadc_thermal.c
20 +++ b/drivers/thermal/mediatek/auxadc_thermal.c
21 @@ -1206,14 +1206,6 @@ static int mtk_thermal_probe(struct plat
23 mt->conf = of_device_get_match_data(&pdev->dev);
25 - mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm");
26 - if (IS_ERR(mt->clk_peri_therm))
27 - return PTR_ERR(mt->clk_peri_therm);
29 - mt->clk_auxadc = devm_clk_get(&pdev->dev, "auxadc");
30 - if (IS_ERR(mt->clk_auxadc))
31 - return PTR_ERR(mt->clk_auxadc);
33 mt->thermal_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
34 if (IS_ERR(mt->thermal_base))
35 return PTR_ERR(mt->thermal_base);
36 @@ -1272,16 +1264,18 @@ static int mtk_thermal_probe(struct plat
40 - ret = clk_prepare_enable(mt->clk_auxadc);
42 + mt->clk_auxadc = devm_clk_get_enabled(&pdev->dev, "auxadc");
43 + if (IS_ERR(mt->clk_auxadc)) {
44 + ret = PTR_ERR(mt->clk_auxadc);
45 dev_err(&pdev->dev, "Can't enable auxadc clk: %d\n", ret);
49 - ret = clk_prepare_enable(mt->clk_peri_therm);
51 + mt->clk_peri_therm = devm_clk_get_enabled(&pdev->dev, "therm");
52 + if (IS_ERR(mt->clk_peri_therm)) {
53 + ret = PTR_ERR(mt->clk_peri_therm);
54 dev_err(&pdev->dev, "Can't enable peri clk: %d\n", ret);
55 - goto err_disable_clk_auxadc;
59 mtk_thermal_turn_on_buffer(mt, apmixed_base);
60 @@ -1305,38 +1299,18 @@ static int mtk_thermal_probe(struct plat
62 tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
64 - if (IS_ERR(tzdev)) {
65 - ret = PTR_ERR(tzdev);
66 - goto err_disable_clk_peri_therm;
69 + return PTR_ERR(tzdev);
71 ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
73 dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
77 -err_disable_clk_peri_therm:
78 - clk_disable_unprepare(mt->clk_peri_therm);
79 -err_disable_clk_auxadc:
80 - clk_disable_unprepare(mt->clk_auxadc);
85 -static int mtk_thermal_remove(struct platform_device *pdev)
87 - struct mtk_thermal *mt = platform_get_drvdata(pdev);
89 - clk_disable_unprepare(mt->clk_peri_therm);
90 - clk_disable_unprepare(mt->clk_auxadc);
95 static struct platform_driver mtk_thermal_driver = {
96 .probe = mtk_thermal_probe,
97 - .remove = mtk_thermal_remove,
99 .name = "mtk-thermal",
100 .of_match_table = mtk_thermal_of_match,