Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp141429rwe; Tue, 18 Apr 2023 19:17:12 -0700 (PDT) X-Google-Smtp-Source: AKy350YVtm+679TqkAU8drOv2HxZL4IUtUTkCRVHlQIS7AzeiaGL1xPD79DUrL3CapvBbr1XnYAX X-Received: by 2002:a05:6a20:e192:b0:ed:1355:f88b with SMTP id ks18-20020a056a20e19200b000ed1355f88bmr1820470pzb.26.1681870632035; Tue, 18 Apr 2023 19:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681870632; cv=none; d=google.com; s=arc-20160816; b=y+DC7kIUqxPBieVbfHcjbvyLppbcWeAgiNWpklfU6Mbu95s/o7J7728GlIB8W7v4uU xAsFkAOREjYWYA2cp9zRtnjT760a9B0C5oTsbsQpZlOb6IXQvZSEJ9ODuTVMJfr0CyKf w0Qw90D25w/OpEJQhvS74bGpubdAd6loxCCKMOnVrckjEMhiiqTD9+LMnPeMWQWlaTR2 1XAyV6TWkU6qX09r/yR7s7WvLY0e9ovL2PcmlA/yB3SmQW76JuzLk7KQLJKVavM8jWQw AykFWBTbMduIhu2+DENwbBk8IL/IPNOa/dDiVKqM/XK8GwKmViSnDB7jPZIzIkNZw7Sp zkIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k/33bWMCjVTHkAxRL+jVkYpwhXgOAclT5cOzRfoL3E4=; b=i4cawHHHoTneZFdAJfnciUqjOWs4j1b8fMAe8z6D4n3qv26L0r57XWL8RRCmsMbVGJ 3ePGbvgfoyNxBea1CmkAbKnH/eMy56xIRISE1yuUsX1Q5EXKoVBh42PB5qir7/V06ZcT aRo0LVhNBBYQtrihDhmW7zdzgFxTNu6DhOkh8VVPis5rEazvykojur5eYseCII7/Ekxg Q/1rzAAqP9bhTDOxhPsuIXe7wbi/rPm0X7h1V085z3yoXB7nSPFiMl2MInPhLCixAjSg DrCMU3HI7QHyOloIinNFnkVK/7cyXDuAxa//3dGi53SOmObqWuwFlFjrxMkYxN/Z2t9y 6+qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z7-20020a6552c7000000b00517a2150d9csi15547090pgp.441.2023.04.18.19.17.00; Tue, 18 Apr 2023 19:17:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231657AbjDSCMX (ORCPT + 99 others); Tue, 18 Apr 2023 22:12:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230153AbjDSCMT (ORCPT ); Tue, 18 Apr 2023 22:12:19 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A893124; Tue, 18 Apr 2023 19:12:17 -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 33J27wUg015429-33J27wUi015429 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 19 Apr 2023 10:08:00 +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, Kang Chen Subject: [PATCH v5 2/2] thermal: mediatek: change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe Date: Wed, 19 Apr 2023 10:07:49 +0800 Message-Id: <20230419020749.621257-2-void0red@hust.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419020749.621257-1-void0red@hust.edu.cn> References: <20230419020749.621257-1-void0red@hust.edu.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: void0red@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Dongliang Mu --- v5 -> v4: use PTR_ERR to convert err ptr to err code v4 -> v3: port to linux-next tree v3 -> v2: remove some useles func calls. v2 -> v1: init drivers/thermal/mediatek/auxadc_thermal.c | 44 +++++------------------ 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/drivers/thermal/mediatek/auxadc_thermal.c b/drivers/thermal/mediatek/auxadc_thermal.c index dcc64237ea60..a488e1797f3d 100644 --- a/drivers/thermal/mediatek/auxadc_thermal.c +++ b/drivers/thermal/mediatek/auxadc_thermal.c @@ -1186,14 +1186,6 @@ static int mtk_thermal_probe(struct platform_device *pdev) mt->conf = of_device_get_match_data(&pdev->dev); - mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm"); - if (IS_ERR(mt->clk_peri_therm)) - return PTR_ERR(mt->clk_peri_therm); - - mt->clk_auxadc = devm_clk_get(&pdev->dev, "auxadc"); - if (IS_ERR(mt->clk_auxadc)) - return PTR_ERR(mt->clk_auxadc); - mt->thermal_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); if (IS_ERR(mt->thermal_base)) return PTR_ERR(mt->thermal_base); @@ -1252,16 +1244,18 @@ static int mtk_thermal_probe(struct platform_device *pdev) if (ret) return ret; - ret = clk_prepare_enable(mt->clk_auxadc); - if (ret) { + mt->clk_auxadc = devm_clk_get_enabled(&pdev->dev, "auxadc"); + if (IS_ERR(mt->clk_auxadc)) { + ret = PTR_ERR(mt->clk_auxadc); dev_err(&pdev->dev, "Can't enable auxadc clk: %d\n", ret); return ret; } - ret = clk_prepare_enable(mt->clk_peri_therm); - if (ret) { + mt->clk_peri_therm = devm_clk_get_enabled(&pdev->dev, "therm"); + if (IS_ERR(mt->clk_peri_therm)) { + ret = PTR_ERR(mt->clk_peri_therm); dev_err(&pdev->dev, "Can't enable peri clk: %d\n", ret); - goto err_disable_clk_auxadc; + return ret; } mtk_thermal_turn_on_buffer(mt, apmixed_base); @@ -1288,38 +1282,18 @@ 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(&pdev->dev, 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) -{ - struct mtk_thermal *mt = platform_get_drvdata(pdev); - - clk_disable_unprepare(mt->clk_peri_therm); - clk_disable_unprepare(mt->clk_auxadc); - - return 0; } static struct platform_driver mtk_thermal_driver = { .probe = mtk_thermal_probe, - .remove = mtk_thermal_remove, .driver = { .name = "mtk-thermal", .of_match_table = mtk_thermal_of_match, -- 2.34.1