From patchwork Fri Aug 18 09:35:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13357554 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77B8FC77B73 for ; Fri, 18 Aug 2023 09:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HZTeQM/rsKkukMjp8m5l2H0GIhQjwXIB9K/zPnyeXO8=; b=QaizTFELvjoMBx wKiicdEtA8pTb4NPiQyv33KH7mUkI3pzmPLm1bbxEI2ZmEMW62wdMRQ7OgX6Py9F1yl4Rh/xPH3jX vgh1gGQiLRzjFN+Q8Etlgz8L1nnohsjgIbfs9AX5msqnv908BBg/Dnu7EYubdlLrOyIArz6wEukN4 Rz8/vI/RQavBYJULn8TR2L8YY18BKcY3fR15oEXHXjneLmS2oHmaJD6w3Gx3U63R/Y3SIqRxo87SG JnwEFffIcr69ewbP9Mf0OHua9UyNRGLGjZX97K7kf9Oj0s8EUItp28BuJLS7lal4akI8wPsLJLwsP 1opA6362Mux88Tu5yrNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWvte-0086h4-2w; Fri, 18 Aug 2023 09:35:58 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWvtc-0086gj-0q for linux-arm-kernel@lists.infradead.org; Fri, 18 Aug 2023 09:35:57 +0000 Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RRxXh0RZ3z1GF9w; Fri, 18 Aug 2023 17:34:28 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 18 Aug 2023 17:35:50 +0800 From: Ruan Jinjie To: , , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team CC: Subject: [PATCH -next] thermal/drivers/imx: Use the devm_clk_get_enabled() helper function Date: Fri, 18 Aug 2023 17:35:24 +0800 Message-ID: <20230818093525.1059106-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230818_023556_533655_3EEF329D X-CRM114-Status: GOOD ( 10.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With devm_clk_get_enabled() the call to clk_disable_unprepare() can be dropped from the error path and the remove callback. Signed-off-by: Ruan Jinjie --- drivers/thermal/imx8mm_thermal.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/imx8mm_thermal.c b/drivers/thermal/imx8mm_thermal.c index e89b11b3f2b9..c74df5de0450 100644 --- a/drivers/thermal/imx8mm_thermal.c +++ b/drivers/thermal/imx8mm_thermal.c @@ -313,16 +313,10 @@ static int imx8mm_tmu_probe(struct platform_device *pdev) if (IS_ERR(tmu->base)) return PTR_ERR(tmu->base); - tmu->clk = devm_clk_get(&pdev->dev, NULL); + tmu->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(tmu->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(tmu->clk), - "failed to get tmu clock\n"); - - ret = clk_prepare_enable(tmu->clk); - if (ret) { - dev_err(&pdev->dev, "failed to enable tmu clock: %d\n", ret); - return ret; - } + "failed to enable tmu clock\n"); /* disable the monitor during initialization */ imx8mm_tmu_enable(tmu, false); @@ -338,7 +332,7 @@ static int imx8mm_tmu_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to register thermal zone sensor[%d]: %d\n", i, ret); - goto disable_clk; + return ret; } tmu->sensors[i].hw_id = i; @@ -349,7 +343,7 @@ static int imx8mm_tmu_probe(struct platform_device *pdev) ret = imx8mm_tmu_probe_set_calib(pdev, tmu); if (ret) - goto disable_clk; + return ret; /* enable all the probes for V2 TMU */ if (tmu->socdata->version == TMU_VER2) @@ -359,10 +353,6 @@ static int imx8mm_tmu_probe(struct platform_device *pdev) imx8mm_tmu_enable(tmu, true); return 0; - -disable_clk: - clk_disable_unprepare(tmu->clk); - return ret; } static int imx8mm_tmu_remove(struct platform_device *pdev) @@ -372,7 +362,6 @@ static int imx8mm_tmu_remove(struct platform_device *pdev) /* disable TMU */ imx8mm_tmu_enable(tmu, false); - clk_disable_unprepare(tmu->clk); platform_set_drvdata(pdev, NULL); return 0;