Re: [PATCH v2 2/2] thermal: mediatek: change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe
From: 陈康
Date: Sun Apr 09 2023 - 23:47:07 EST
> -----原始邮件-----
> 发件人: "Kang Chen" <void0red@xxxxxxxxxxx>
> 发送时间: 2023-04-04 00:46:10 (星期二)
> 收件人: daniel.lezcano@xxxxxxxxxx
> 抄送: amitk@xxxxxxxxxx, angelogioacchino.delregno@xxxxxxxxxxxxx, bchihi@xxxxxxxxxxxx, daniel@xxxxxxxxxxxxxx, dzm91@xxxxxxxxxxx, error27@xxxxxxxxx, henry.yen@xxxxxxxxxxxx, hust-os-kernel-patches@xxxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-mediatek@xxxxxxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, matthias.bgg@xxxxxxxxx, rafael@xxxxxxxxxx, rdunlap@xxxxxxxxxxxxx, rui.zhang@xxxxxxxxx, void0red@xxxxxxxxx, void0red@xxxxxxxxxxx
> 主题: [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@xxxxxxxxxxx>
> ---
> 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
ping?