From patchwork Mon Nov 20 14:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Majewski X-Patchwork-Id: 745550 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73675C2BB3F for ; Mon, 20 Nov 2023 14:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233506AbjKTOwW (ORCPT ); Mon, 20 Nov 2023 09:52:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233949AbjKTOwB (ORCPT ); Mon, 20 Nov 2023 09:52:01 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 358101718 for ; Mon, 20 Nov 2023 06:51:08 -0800 (PST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231120145105euoutp02b14aca2a1956606869dab37ec39176d5~ZXFeHX61i2495924959euoutp02L for ; Mon, 20 Nov 2023 14:51:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231120145105euoutp02b14aca2a1956606869dab37ec39176d5~ZXFeHX61i2495924959euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1700491865; bh=SZ2xtU4liTdPRXyiaem1RPsDZRIMzUg5tNmbRIlLQxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MRkMYLgECGbDZuAC16i7Z074sz03zc/RS5f2Hw8GceDNDV+vlQL3f6Hz6B8dZLFXg dfoFQE2ehoktZUrvfmHDgeoqbYwA8/yNkVQ/mae6RfjuVu61l1X5XzSACBiIhs6E9x Fbx5M0f4jWAylM8bNH40D+mGJz4m9lQ/O1RkrF/I= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231120145104eucas1p20f74dc6a127503ebc00e387d9a634902~ZXFdrO2ae2766127661eucas1p2J; Mon, 20 Nov 2023 14:51:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 26.A8.09552.8527B556; Mon, 20 Nov 2023 14:51:04 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231120145104eucas1p122668d13b89b1f65356ab7cb717e9a5e~ZXFdOx-sO2333923339eucas1p13; Mon, 20 Nov 2023 14:51:04 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231120145104eusmtrp25207acc34ecc76f70f09d81a87362d22~ZXFdOCmlr0700707007eusmtrp2p; Mon, 20 Nov 2023 14:51:04 +0000 (GMT) X-AuditID: cbfec7f5-83dff70000002550-88-655b72587fd2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 28.C3.09146.8527B556; Mon, 20 Nov 2023 14:51:04 +0000 (GMT) Received: from AMDC4515.eu.corp.samsungelectronics.net (unknown [106.120.51.28]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231120145103eusmtip2b3b3275f2c9b17d5489c7bc9310ab4d1~ZXFcYf-wn1340113401eusmtip2D; Mon, 20 Nov 2023 14:51:03 +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 Subject: [PATCH v5 5/9] thermal: exynos: simplify regulator (de)initialization Date: Mon, 20 Nov 2023 15:50:45 +0100 Message-ID: <20231120145049.310509-6-m.majewski2@samsung.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231120145049.310509-1-m.majewski2@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOKsWRmVeSWpSXmKPExsWy7djP87oRRdGpBkf+a1s8mLeNzeLw/AqL qQ+fsFl833KdyWLeZ1mLva+3slt8u9LBZLHp8TVWi8u75rBZfO49wmgx4/w+JouFTS3sFhOP TWa2WHvkLrvF3C9TmS2ePOxjcxDwWDNvDaPHzll32T0W73nJ5LFpVSebx51re9g8Ni+p9+jb sorR4/MmuQCOKC6blNSczLLUIn27BK6M7xc2shSskKuYPHkVYwPjbokuRk4OCQETiXNX77GA 2EICKxglGl8A2VxA9hdGiYMN7xghnM+MEpNnvWGH6diydz8rRGI5o8TzC0eZIZxWJolty6+C zWITMJB48GYZWIeIQCujxMwmdZAiZoGvzBJXX89nBkkICwRITP17E6yBRUBV4uSzhWwgNq+A rUT/g8dMEOvkJfYs+g5mcwrYSbQdeQ5VIyhxcuYTsF5moJrmrbPBrpAQ6OeU6Pp6BqrZRWL7 44dQtrDEq+NboH6Qkfi/cz5UPF9ixub3QIM4gOwKibsHvSBMa4mPZ5hBTGYBTYn1u/Qhoo4S Z8/XQJh8EjfeCkLs55OYtG06M0SYV6KjTQhisqrE8T2TmCFsaYknLbehNnpI/H+/lmkCo+Is JJ/MQvLJLIS1CxiZVzGKp5YW56anFhvnpZbrFSfmFpfmpesl5+duYgSmtdP/jn/dwbji1Ue9 Q4xMHIyHGCU4mJVEeL8JRaQK8aYkVlalFuXHF5XmpBYfYpTmYFES51VNkU8VEkhPLEnNT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LU0M1YS5/Us6EgUEkhPLEnNTk0tSC2C6WPi4JRqYFomfiSu J/b5u26hB9wTbVm0KztKJsdl2R8zXzpP769w9O7kDQ0TLkTn5GjrMbxs8PPjkfgUEnTrw7NI 8z3pf2VTeif7KOnZxS9YacJV13L6ayBTuP/3MPWA86ZpCeHa3csqbQqmG20INr4w+QbTNf5l SYxbquX1Tj1KUJGqOahW8EXG8g6bnPyaH/9VRTbJf75pbX4uuKam0tD6usilyQ+Ts8Kva7JE GX4tEZh9u7Zq35qrwtHHG+3Yr96/0enY9u/toefrvs/PaEld6Hll0pWIgz753qV/gnQXnZMy 2f1KJO+CFMulbaGlTLtOXdbmdLE51tpb+G6z7bNb5rx8L73PZ/+9F3fxSPHVGvFNSizFGYmG WsxFxYkASoVY4kwDAAA= X-CMS-MailID: 20231120145104eucas1p122668d13b89b1f65356ab7cb717e9a5e X-Msg-Generator: CA X-RootMTR: 20231120145104eucas1p122668d13b89b1f65356ab7cb717e9a5e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231120145104eucas1p122668d13b89b1f65356ab7cb717e9a5e References: <20231120145049.310509-1-m.majewski2@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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