From patchwork Fri Dec 1 09:56:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Majewski X-Patchwork-Id: 13475588 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 50AD8C4167B for ; Fri, 1 Dec 2023 09:57:20 +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:References:MIME-Version:In-Reply-To: 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: List-Owner; bh=Ao31GGYGKJfcQrojxrHdciQpEbt8Pxgnf6pv9exRD+0=; b=dBZ5or73jUmpxe unTyNTKUKSk99O+P5zd/kWL7NY9cJdnSWWkahP3QF+8/bzZDy+a6f8MStHINPL2Tc/e9Oe1SPT9Mi 0yNuG3Ct5bqe1GBBwYXm/WWl3+ES/qtrPGeA3XVWomWpFn2tOXBbyQdtItMD9AY31fOD9ZKCiQsWa sySVpTnSPsW8edU2r41rxbLnhvKvMmOpuWFhPJxS3dS78cyew+auEoykKleyxDO88iCo+doG6K1+B pt9z8JWAVp2Aj4HbbUBbFdUnSvB5kld+LaYBeYJLpIp6bLm3T9LVwJx+DduI1nVfes2R9zfrokMFu jxtnxhujy8ggQEYuDvNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r90GU-00D90P-0K; Fri, 01 Dec 2023 09:56:54 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r90GN-00D8vN-0S for linux-arm-kernel@lists.infradead.org; Fri, 01 Dec 2023 09:56:50 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231201095645euoutp024b3db2e9ecfef09f1802cb58bb855704~crKocqVn40606406064euoutp028 for ; Fri, 1 Dec 2023 09:56:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231201095645euoutp024b3db2e9ecfef09f1802cb58bb855704~crKocqVn40606406064euoutp028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1701424605; bh=SZ2xtU4liTdPRXyiaem1RPsDZRIMzUg5tNmbRIlLQxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPdqa/PA8VB5f9dzFdPqruddLjVrn9V9TtFFUU61fgVec6noMvfMMqZZF8eYVtm17 0sMH9Q4hHPo5v/H930Whpx9foV6vfXWnvuX/HegKRoU/mm5e/6xlrrIKZNM7gfBZVQ 8XXgDd1mbfhWYeocRLepma08OpCWUwE59IDuYdH8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20231201095645eucas1p1540cfcf24aeb003fddd7fba1142877bb~crKn5IlAo2916929169eucas1p19; Fri, 1 Dec 2023 09:56:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D8.42.09814.DDDA9656; Fri, 1 Dec 2023 09:56:45 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231201095644eucas1p1818772bfce0bbf2109ec5fbf928f603a~crKndfPZS0264702647eucas1p17; Fri, 1 Dec 2023 09:56:44 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231201095644eusmtrp1355d61e56b3522ef2f4d5966cf96dbbb~crKnbZVWJ0736407364eusmtrp1E; Fri, 1 Dec 2023 09:56:44 +0000 (GMT) X-AuditID: cbfec7f4-727ff70000002656-f6-6569adddb029 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9C.20.09146.CDDA9656; Fri, 1 Dec 2023 09:56:44 +0000 (GMT) Received: from AMDC4515.eu.corp.samsungelectronics.net (unknown [106.120.51.28]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231201095643eusmtip2f56a985d7babd097d0d614b1d6d6d9e3~crKmjGzh21190911909eusmtip26; Fri, 1 Dec 2023 09:56:43 +0000 (GMT) From: Mateusz Majewski To: linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Mateusz Majewski , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Alim Akhtar , Liam Girdwood , Mark Brown , Marek Szyprowski , Lukasz Luba , Dan Carpenter Subject: [PATCH v6 5/9] thermal: exynos: simplify regulator (de)initialization Date: Fri, 1 Dec 2023 10:56:21 +0100 Message-ID: <20231201095625.301884-6-m.majewski2@samsung.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201095625.301884-1-m.majewski2@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFKsWRmVeSWpSXmKPExsWy7djP87p312amGly5yGPxYN42NovD8yss pj58wmbxfct1JosP81rZLeZ9lrXY+3oru8W3Kx1MFpseX2O1uLxrDpvF594jjBYzzu9jsljY 1MJuMfHYZGaLtUfuslvM/TKV2eLJwz42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AAA== X-CMS-MailID: 20231201095644eucas1p1818772bfce0bbf2109ec5fbf928f603a X-Msg-Generator: CA X-RootMTR: 20231201095644eucas1p1818772bfce0bbf2109ec5fbf928f603a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231201095644eucas1p1818772bfce0bbf2109ec5fbf928f603a References: <20231201095625.301884-1-m.majewski2@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_015647_443361_4CA057A9 X-CRM114-Status: GOOD ( 18.52 ) 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 We rewrite the initialization to enable the regulator as part of devm, which allows us to not handle the struct instance manually. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mateusz Majewski --- v3 -> v4: Resolved merge conflict and moved info about not outputting error to the correct commit message. v2 -> v3: Fixed error handling of devm_regulator_get_optional to handle the case in which the regulator is available, but enabling it fails. Also removed the error message, split into two commits and reworded the commit message. drivers/thermal/samsung/exynos_tmu.c | 49 +++++++++------------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 8bcad8a70dc5..3bdcbab7466f 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -157,7 +157,6 @@ enum soc_type { * @reference_voltage: reference voltage of amplifier * in the positive-TC generator block * 0 < reference_voltage <= 31 - * @regulator: pointer to the TMU regulator structure. * @tzd: pointer to thermal_zone_device structure * @ntrip: number of supported trip points. * @enabled: current status of TMU device @@ -183,7 +182,6 @@ struct exynos_tmu_data { u16 temp_error1, temp_error2; u8 gain; u8 reference_voltage; - struct regulator *regulator; struct thermal_zone_device *tzd; unsigned int ntrip; bool enabled; @@ -994,50 +992,40 @@ static int exynos_tmu_probe(struct platform_device *pdev) * TODO: Add regulator as an SOC feature, so that regulator enable * is a compulsory call. */ - data->regulator = devm_regulator_get_optional(&pdev->dev, "vtmu"); - if (!IS_ERR(data->regulator)) { - ret = regulator_enable(data->regulator); - if (ret) { - dev_err(&pdev->dev, "failed to enable vtmu\n"); - return ret; - } - } else { - ret = PTR_ERR(data->regulator); - switch (ret) { - case -ENODEV: - break; - case -EPROBE_DEFER: - return -EPROBE_DEFER; - default: - dev_err(&pdev->dev, "Failed to get regulator: %d\n", - ret); - return ret; - } + ret = devm_regulator_get_enable_optional(&pdev->dev, "vtmu"); + switch (ret) { + case 0: + case -ENODEV: + break; + case -EPROBE_DEFER: + return -EPROBE_DEFER; + default: + dev_err(&pdev->dev, "Failed to get enabled regulator: %d\n", + ret); + return ret; } ret = exynos_map_dt_data(pdev); if (ret) - goto err_sensor; + return ret; data->clk = devm_clk_get(&pdev->dev, "tmu_apbif"); if (IS_ERR(data->clk)) { dev_err(&pdev->dev, "Failed to get clock\n"); - ret = PTR_ERR(data->clk); - goto err_sensor; + return PTR_ERR(data->clk); } data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif"); if (IS_ERR(data->clk_sec)) { if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) { dev_err(&pdev->dev, "Failed to get triminfo clock\n"); - ret = PTR_ERR(data->clk_sec); - goto err_sensor; + return PTR_ERR(data->clk_sec); } } else { ret = clk_prepare(data->clk_sec); if (ret) { dev_err(&pdev->dev, "Failed to get clock\n"); - goto err_sensor; + return ret; } } @@ -1107,10 +1095,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_clk_sec: if (!IS_ERR(data->clk_sec)) clk_unprepare(data->clk_sec); -err_sensor: - if (!IS_ERR(data->regulator)) - regulator_disable(data->regulator); - return ret; } @@ -1124,9 +1108,6 @@ static void exynos_tmu_remove(struct platform_device *pdev) clk_unprepare(data->clk); if (!IS_ERR(data->clk_sec)) clk_unprepare(data->clk_sec); - - if (!IS_ERR(data->regulator)) - regulator_disable(data->regulator); } #ifdef CONFIG_PM_SLEEP