From patchwork Fri Jul 19 12:08:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Majewski X-Patchwork-Id: 13737252 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 9D8CBC3DA5D for ; Fri, 19 Jul 2024 12:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:References:Content-Type: Content-Transfer-Encoding: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=Nh0TJi293rn5IE+Jt9huGdfdtzwSXb2zQOIamLrmk2c=; b=NmnMttUTQ6TvnAWOqjN5bFMqkL C9UvV9WLKaRAka8cfMCg6ZQrcXeZpN/gcQnoTKAylP/UETXwFp7zuV3bwFAHjPX8yYsTN2tMj/ybt A4gtwYnZwwAh5uwNPqnV3Xu7CRo1Jux6axpMYT/tHugwNDKt9ikfXnvAWcwrVCJou++jom8lOIpWj gt9coHfRNPTE3OjmwdvdBBQNWocgHlhUkA7kITHbNr0++0Xjg2C4b2OPS2ksQ8J9YThjplZ/Get0C H3Ijhwh8a847DmIoYDI7LXWkgKJn4Shwqd7auYFE+KVT1CwwXkYD9eEsipRp6tzsIzPBFPHHNoiz1 Zhs+/6uA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUmSW-00000002bEn-12e9; Fri, 19 Jul 2024 12:11:36 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUmQo-00000002aZa-2L0n for linux-arm-kernel@lists.infradead.org; Fri, 19 Jul 2024 12:09:54 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240719120947euoutp020cee0c622450e2e64193cf1d02aa443b~jm-ufwJvf2413724137euoutp02D for ; Fri, 19 Jul 2024 12:09:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240719120947euoutp020cee0c622450e2e64193cf1d02aa443b~jm-ufwJvf2413724137euoutp02D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1721390987; bh=Nh0TJi293rn5IE+Jt9huGdfdtzwSXb2zQOIamLrmk2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dTFSjVDBxEyDh/GBYfJeLYtNJ6zpmgZMXKKR8wqjM5F+OvzvupoGgy5xZ+jGp4Hbd V3W1mJ/NTm+OO8pkaHpfIXcZirRnLzRw6+j3+/G23rG3FFtQrKDmu4plok6cpsJGvU 8w/9mxP9+F5RhC3T4jdeGQUUtVfxjnAAwDUGYGX8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20240719120947eucas1p16f286d7036064242cc2ea94cbc05d937~jm-uJIicr0450904509eucas1p1k; Fri, 19 Jul 2024 12:09:47 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FC.81.09620.B875A966; Fri, 19 Jul 2024 13:09:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240719120946eucas1p1b565fa653d33aa2155cd3bb172c29d14~jm-tmLTgg2864628646eucas1p1t; Fri, 19 Jul 2024 12:09:46 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240719120946eusmtrp1697650eb63aa7cd3aebc2f0da878cab9~jm-tlZkNU0596405964eusmtrp1c; Fri, 19 Jul 2024 12:09:46 +0000 (GMT) X-AuditID: cbfec7f5-d1bff70000002594-ff-669a578bb623 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id DC.85.08810.A875A966; Fri, 19 Jul 2024 13:09:46 +0100 (BST) Received: from AMDC4515.eu.corp.samsungelectronics.net (unknown [106.120.51.28]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240719120945eusmtip145c6651961e7d2ceefbd4e3d1488fd0d~jm-s0M3tT0493704937eusmtip1f; Fri, 19 Jul 2024 12:09:45 +0000 (GMT) From: Mateusz Majewski To: linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@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 , Zhang Rui , Lukasz Luba , Rob Herring , Conor Dooley , Alim Akhtar Subject: [PATCH 3/6] drivers/thermal/exynos: check IS_ERR(data->clk) consistently Date: Fri, 19 Jul 2024 14:08:47 +0200 Message-ID: <20240719120853.1924771-4-m.majewski2@samsung.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240719120853.1924771-1-m.majewski2@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCKsWRmVeSWpSXmKPExsWy7djP87rd4bPSDH7MZrZ4MG8bm8X3LdeZ LNbsPcdkMe+zrMX8I+dYLc6f38BusenxNVaLy7vmsFl87j3CaDHj/D4mi4VNLewWE49N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izFGYmGWsxF xYkAJeWFB0kDAAA= X-CMS-MailID: 20240719120946eucas1p1b565fa653d33aa2155cd3bb172c29d14 X-Msg-Generator: CA X-RootMTR: 20240719120946eucas1p1b565fa653d33aa2155cd3bb172c29d14 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240719120946eucas1p1b565fa653d33aa2155cd3bb172c29d14 References: <20240719120853.1924771-1-m.majewski2@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240719_050951_263712_D5265E3F X-CRM114-Status: GOOD ( 18.00 ) 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 This will be needed for Exynos 850 support, which does not require this clock. It would also be possible to set data->clk to NULL instead, but doing it like this is consistent with what we do with data->clk_sec. Signed-off-by: Mateusz Majewski --- drivers/thermal/samsung/exynos_tmu.c | 58 ++++++++++++++++++---------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 61606a9b9a00..f0de72a62fd7 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -257,7 +257,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) int ret = 0; mutex_lock(&data->lock); - clk_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_enable(data->clk); if (!IS_ERR(data->clk_sec)) clk_enable(data->clk_sec); @@ -271,7 +272,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) if (!IS_ERR(data->clk_sec)) clk_disable(data->clk_sec); - clk_disable(data->clk); + if (!IS_ERR(data->clk)) + clk_disable(data->clk); mutex_unlock(&data->lock); return ret; @@ -295,11 +297,13 @@ static int exynos_thermal_zone_configure(struct platform_device *pdev) } mutex_lock(&data->lock); - clk_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_enable(data->clk); data->tmu_set_crit_temp(data, temp / MCELSIUS); - clk_disable(data->clk); + if (!IS_ERR(data->clk)) + clk_disable(data->clk); mutex_unlock(&data->lock); return 0; @@ -328,10 +332,12 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) struct exynos_tmu_data *data = platform_get_drvdata(pdev); mutex_lock(&data->lock); - clk_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_enable(data->clk); data->tmu_control(pdev, on); data->enabled = on; - clk_disable(data->clk); + if (!IS_ERR(data->clk)) + clk_disable(data->clk); mutex_unlock(&data->lock); } @@ -648,7 +654,8 @@ static int exynos_get_temp(struct thermal_zone_device *tz, int *temp) return -EAGAIN; mutex_lock(&data->lock); - clk_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_enable(data->clk); value = data->tmu_read(data); if (value < 0) @@ -656,7 +663,8 @@ static int exynos_get_temp(struct thermal_zone_device *tz, int *temp) else *temp = code_to_temp(data, value) * MCELSIUS; - clk_disable(data->clk); + if (!IS_ERR(data->clk)) + clk_disable(data->clk); mutex_unlock(&data->lock); return ret; @@ -723,9 +731,11 @@ static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp) goto out; mutex_lock(&data->lock); - clk_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_enable(data->clk); data->tmu_set_emulation(data, temp); - clk_disable(data->clk); + if (!IS_ERR(data->clk)) + clk_disable(data->clk); mutex_unlock(&data->lock); return 0; out: @@ -763,12 +773,14 @@ static irqreturn_t exynos_tmu_threaded_irq(int irq, void *id) thermal_zone_device_update(data->tzd, THERMAL_EVENT_UNSPECIFIED); mutex_lock(&data->lock); - clk_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_enable(data->clk); /* TODO: take action based on particular interrupt */ data->tmu_clear_irqs(data); - clk_disable(data->clk); + if (!IS_ERR(data->clk)) + clk_disable(data->clk); mutex_unlock(&data->lock); return IRQ_HANDLED; @@ -979,7 +991,8 @@ static int exynos_set_trips(struct thermal_zone_device *tz, int low, int high) struct exynos_tmu_data *data = thermal_zone_device_priv(tz); mutex_lock(&data->lock); - clk_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_enable(data->clk); if (low > INT_MIN) data->tmu_set_low_temp(data, low / MCELSIUS); @@ -990,7 +1003,8 @@ static int exynos_set_trips(struct thermal_zone_device *tz, int low, int high) else data->tmu_disable_high(data); - clk_disable(data->clk); + if (!IS_ERR(data->clk)) + clk_disable(data->clk); mutex_unlock(&data->lock); return 0; @@ -1053,10 +1067,12 @@ static int exynos_tmu_probe(struct platform_device *pdev) } } - ret = clk_prepare(data->clk); - if (ret) { - dev_err(dev, "Failed to get clock\n"); - goto err_clk_sec; + if (!IS_ERR(data->clk)) { + ret = clk_prepare(data->clk); + if (ret) { + dev_err(dev, "Failed to get clock\n"); + goto err_clk_sec; + } } switch (data->soc) { @@ -1113,7 +1129,8 @@ static int exynos_tmu_probe(struct platform_device *pdev) err_sclk: clk_disable_unprepare(data->sclk); err_clk: - clk_unprepare(data->clk); + if (!IS_ERR(data->clk)) + clk_unprepare(data->clk); err_clk_sec: if (!IS_ERR(data->clk_sec)) clk_unprepare(data->clk_sec); @@ -1127,7 +1144,8 @@ static void exynos_tmu_remove(struct platform_device *pdev) exynos_tmu_control(pdev, false); clk_disable_unprepare(data->sclk); - clk_unprepare(data->clk); + if (!IS_ERR(data->clk)) + clk_unprepare(data->clk); if (!IS_ERR(data->clk_sec)) clk_unprepare(data->clk_sec); }