From patchwork Tue Oct 3 11:16:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Majewski X-Patchwork-Id: 13407469 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 1C4BFE7544B for ; Tue, 3 Oct 2023 11:17:41 +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=QShU9x4igauFE2143vXTtA0r+B8IU3mphW0PxOZvbTg=; b=zePbB+RI8A+qgT I4g3XpbYamdVXg6KvpDnyoiFLPODnpCq92zTfllMdY0Rab9dhiE8y2+75007aIDbY/oYqbV3161BO vsDrNwU/Ho21RawWLbUxDHUh1nv4W/3ztOZY2bNorKCMr1mdBcBcv71N29/m9EnZYDpCOmTk5Ux8+ rHJbY/c5Wi+3acOcFg8/sm58trWel4wt9S5uiBLF7Z97mZN2QIW2WdYHKufVDIiVWNiQ/KDvEu40M 7Qwa5u0JUjW37KYqa09T7kLKo9HcGTQXNU2QEmjAvwJo8kzqFQdHIJv4SrSWe/hoBFpAPllXDIb91 MikO6fB/TunbS9qa7yBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qndOw-00EVsR-12; Tue, 03 Oct 2023 11:17:18 +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 1qndOr-00EVp3-14 for linux-arm-kernel@lists.infradead.org; Tue, 03 Oct 2023 11:17:15 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231003111712euoutp02b0f2581334a4e7eb92d099b1ebe3cf22~KlNBSn2V81158311583euoutp02h for ; Tue, 3 Oct 2023 11:17:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231003111712euoutp02b0f2581334a4e7eb92d099b1ebe3cf22~KlNBSn2V81158311583euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1696331832; bh=V2/Mzb3I7DEQaqQIC0PslVbUjHF4j1Sq8nv+9t2b3y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ID8Z0dMgZk+xiF2qNL2+N6JaBTVz382TOqb5TM/xLHmD7qDMPhtEm3fGceNm90zfS FsVx34UX8I+7D5i4c5fN5mnl4p1i7Ee5PHyqX4RcgCx/HCuhKK3rNo5qOdPzPa2vLg H9QUV2HqJNoIEujnW73FVqm8EsS9Jbpj/nW4m80o= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20231003111711eucas1p1628e726b548802c3befcd088761ae329~KlNA48lQA2460224602eucas1p1x; Tue, 3 Oct 2023 11:17:11 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D4.2F.37758.738FB156; Tue, 3 Oct 2023 12:17:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231003111711eucas1p2646dcfd2d7d473b78b012153bca06cc7~KlNASNH_30433204332eucas1p2N; Tue, 3 Oct 2023 11:17:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231003111711eusmtrp1323c66d180ae07f5752a597299e8ac54~KlNARkQSH2239722397eusmtrp1B; Tue, 3 Oct 2023 11:17:11 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-e5-651bf837e354 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 80.DE.25043.638FB156; Tue, 3 Oct 2023 12:17:10 +0100 (BST) Received: from AMDC4515.eu.corp.samsungelectronics.net (unknown [106.120.51.28]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231003111710eusmtip2f6c814e4b6d39c4deec3ca73aa73b069~KlM-ax1nA2844228442eusmtip2E; Tue, 3 Oct 2023 11:17:10 +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 Subject: [PATCH v3 5/8] thermal: exynos: simplify regulator (de)initialization Date: Tue, 3 Oct 2023 13:16:31 +0200 Message-ID: <20231003111638.241542-6-m.majewski2@samsung.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231003111638.241542-1-m.majewski2@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLKsWRmVeSWpSXmKPExsWy7djP87rmP6RTDT5sULZ4MG8bm8Xh+RUW Ux8+YbP4vuU6k8W8z7IWe19vZbf4dqWDyWLT42usFpd3zWGz+Nx7hNFixvl9TBYTj01mtlh7 5C67xdwvU5ktnjzsY3Pg99g56y67x+I9L5k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cfd2d7d473b78b012153bca06cc7 X-Msg-Generator: CA X-RootMTR: 20231003111711eucas1p2646dcfd2d7d473b78b012153bca06cc7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231003111711eucas1p2646dcfd2d7d473b78b012153bca06cc7 References: <20231003111638.241542-1-m.majewski2@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231003_041713_636128_8BA6DBC7 X-CRM114-Status: GOOD ( 19.93 ) 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. We also remove the error message in case the regulator is unavailable, as this is expected behaviour. Signed-off-by: Mateusz Majewski Reviewed-by: Krzysztof Kozlowski --- 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 6070b03cff9d..a0a1f7e1e63f 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; } @@ -1125,9 +1109,6 @@ static int exynos_tmu_remove(struct platform_device *pdev) if (!IS_ERR(data->clk_sec)) clk_unprepare(data->clk_sec); - if (!IS_ERR(data->regulator)) - regulator_disable(data->regulator); - return 0; }