Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4837386rwl; Mon, 3 Apr 2023 10:14:30 -0700 (PDT) X-Google-Smtp-Source: AKy350YcdlVSMvZg9BakiuJH/72UMq8uefr17i2JJYlXKGmaajfZRgKnbhuDQU+QVfTNp3bjO2iM X-Received: by 2002:a05:6a00:4e:b0:628:a3d:8aa7 with SMTP id i14-20020a056a00004e00b006280a3d8aa7mr37765690pfk.31.1680542070517; Mon, 03 Apr 2023 10:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680542070; cv=none; d=google.com; s=arc-20160816; b=NKl1uDvkYGQP7cDxOkv7PNMk6ZZWNCczaGByTiukkGa39+E3cBV5y8I9LfpZmRHvvh 156il4JhRRc3vvCts9wE+ZlHxGy2hVfWLVesll24e7Kwixjw6SSigyCLxGriQwUNt1ik zA8oK3qBxyXNuxjHGHp/jEBEfFOpyWahAvXIkeL+H66v1km0VTQyE7vb/mAafAqdwQ/a VvZNJlUFmJqihy6RAdMFZMOIWfJcHHGMT3EXcZY+nq5fBdqmPrvgjFjZphW0zq3UHgQQ AbLxcgC0ymtJOfydZMqDs0XBo0l7Lp/elo4N7G+rJiTyTl06hIl02idFi0IlXYxfa9zn o4Gg== 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=pmAi/Z1rlBfNKaCRlWLlCDkew8mH2p49s4pTlukDXDo=; b=t2F3JGdRlgWJ1CuJZCjFiqL/ARa9l3tmaw5S8UH1iDW6tYpFBrvHOkwo5bNdEjkFhB 4I4W1YzSk5+BPvXBHgXq7qZ5nh737KXx/VBWbmzi1UsV0DyCsjmccf1xZwMtBMaSe9ka j7Nm8afrm/jtFd/RVzAM1QCWevhnCezJoFbxYtpHvuqW4GbMb9jZUkkQmx4CFSyJlsaE w2Ad/9kGMFqQe+ocOpFf8KaTCkca9gMNw9bTRoIo/MifM8gqAj+v42MhUCqUdKOMUs9L Gd7NhzsDrtp9+Vq4uz80OXh7cdA1s5TU8YeDQc0gtq+M5r2rcbNO19zAKUfUJLO30Udu cA4Q== 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 q25-20020aa78439000000b00622bad41034si8828855pfn.95.2023.04.03.10.14.18; Mon, 03 Apr 2023 10:14:30 -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 S232902AbjDCQsl (ORCPT + 99 others); Mon, 3 Apr 2023 12:48:41 -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 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: void0red@hust.edu.cn X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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. 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) -- 2.34.1