From patchwork Mon Apr 3 16:46:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kang Chen X-Patchwork-Id: 669990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A27FAC761AF for ; Mon, 3 Apr 2023 16:48:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232927AbjDCQsk (ORCPT ); Mon, 3 Apr 2023 12:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232897AbjDCQsi (ORCPT ); Mon, 3 Apr 2023 12:48:38 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C600268A; Mon, 3 Apr 2023 09:48:33 -0700 (PDT) Received: from passwd123-ThinkStation-P920.. ([222.20.94.23]) (user=void0red@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 333GkBiv000418-333GkBix000418 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 4 Apr 2023 00:46:12 +0800 From: Kang Chen To: daniel.lezcano@linaro.org Cc: amitk@kernel.org, angelogioacchino.delregno@collabora.com, bchihi@baylibre.com, daniel@makrotopia.org, dzm91@hust.edu.cn, error27@gmail.com, henry.yen@mediatek.com, hust-os-kernel-patches@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, matthias.bgg@gmail.com, rafael@kernel.org, rdunlap@infradead.org, rui.zhang@intel.com, void0red@gmail.com, void0red@hust.edu.cn Subject: [PATCH v2 2/2] thermal: mediatek: change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe Date: Tue, 4 Apr 2023 00:46:10 +0800 Message-Id: <20230403164610.3608082-2-void0red@hust.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403164610.3608082-1-void0red@hust.edu.cn> References: <6e3c59c3-8ad0-9c53-62a4-7be6f55a7c02@linaro.org> <20230403164610.3608082-1-void0red@hust.edu.cn> MIME-Version: 1.0 X-FEAS-AUTH-USER: void0red@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org use devm_clk_get_enabled to do automatic resource management. Signed-off-by: Kang Chen --- 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)