From patchwork Mon Sep 26 14:05:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988742 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 17741C32771 for ; Mon, 26 Sep 2022 14:07:47 +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:References: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=mhfzgrom5oSav0O10og4H71uF7hH8UgHMowPkjlWf58=; b=aYfXqrj1XqfICZ EP9xZd/1IilhfBvvzmgNDnQp8nz9dKGiVKDgDWLbScw4Bj3T9CK/qB3faYg1GPnNMlCJQfvzAdFUY auzBIMQM8BgqX3Rjk+EhrMFSYEgrg5nfCVCFgS7kHA9nTBpH+FEGa3ZPaxWOpo0xizUJgd/oqCCk4 StjTp6SqlFm7h2DvMt5eQcMZkTJZ2QbMVMRa3neyaS3N1tqfD2sIVYvWVbO/EtrPTMxC0NhnFI/LC jP/NA4MDPdL9WAlg1O5vj+dch+dwNzveLro2c6vO4nNgfmjCtoF28It7LhWcwzsUCs/fej7RETZLO jdrenHQPg2386TjZNC8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocokh-005GhM-PE; Mon, 26 Sep 2022 14:06:31 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocokf-005GgI-BV for linux-arm-kernel@lists.infradead.org; Mon, 26 Sep 2022 14:06:30 +0000 Received: by mail-wr1-x42c.google.com with SMTP id x18so10393408wrm.7 for ; Mon, 26 Sep 2022 07:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=Q23c4HAkgnl6Z9MaLlFBlkJQVlfuiThqrS8mJukwVIImKsYum75U4XdgrkNKk/0lwy lJzQv8+rsPlnw3WHwSmLxe9y/2uppUm+i374ZBcbjH37fLsr40lP26hZuauGkID+qu/1 rkApvZIf8Uu9MEmrkKhZJr53pIANT6XnDdzR5+74zNMG7IulxvRiGCWOyqJHhtiPgm/W REvizDF2fQ/Wa8Jg+yFs01HqT+Kb1zrvk4flQq8vtWLbINHUIegDGwW8rbkwsVlD8Bkj 7txsRB08UgJlDH24uEb550keyWuhzfNb+XK4KY7FG9iGIVaHBjHGW2Wl7RU4Sgi+g4pO ZLow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=DMcOlUObijg8F6AZuYM2bwUdlmzjELGL7gsjEQETQNW8+p7ZzB0b/WLNYZdP1mKiGp 4QjngpNthxFXuYf2ILVtwKqnzC+OzBLTHWFcDjKfygTDtWakEPC8AGkg7YVGOTLDH/zD L31F2qG2RJnHenSoN34y6ClQnO1zTapGFzOnj1fDTeQ/e9epIOocFqASqYTZKawmuxjw vxBDqUmj8VU+KWGzCPQkvhm61VTM9/7xRT9AqaLWtZrqo55etMDN4aniDnLkeTyRy0lM qEccWjzAmOAPTJnLHbSN5X1JOR8k0DNFt+42CbRVmzchR0KIQUUdJOgImzL9X9cuIuKn rWmg== X-Gm-Message-State: ACrzQf0zuy26ihzRYDVp5M3tKnbN6JMGPsT0oMZQW0PGofmdHJxeINno XJV81vEAAWKTgD47FOR0dqcLmw== X-Google-Smtp-Source: AMsMyM6rJqmC1nrOEeRLrZJBMGkup0bYQbcQRJMYdBAN9BZM81uzWYQNn0pJhWUuTj55jrrdI43ezw== X-Received: by 2002:a5d:6147:0:b0:22a:6035:a878 with SMTP id y7-20020a5d6147000000b0022a6035a878mr13188016wrt.528.1664201187409; Mon, 26 Sep 2022 07:06:27 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:26 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v5 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:42 +0200 Message-Id: <20220926140604.4173723-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220926_070629_418760_CE60461B X-CRM114-Status: GOOD ( 16.95 ) 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 The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 41 +++++++++++----------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 51874d0a284c..0e33d32a9d2e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,16 +260,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tzd = data->tzd; - const struct thermal_trip * const trips = - of_thermal_get_trip_points(tzd); unsigned int status; - int ret = 0, temp, hyst; - - if (!trips) { - dev_err(&pdev->dev, - "Cannot get trip points from device tree!\n"); - return -ENODEV; - } + int ret = 0, temp; if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */ ret = tzd->ops->get_crit_temp(tzd, &temp); @@ -303,19 +295,16 @@ static int exynos_tmu_initialize(struct platform_device *pdev) /* Write temperature code for rising and falling threshold */ for (i = 0; i < ntrips; i++) { - /* Write temperature code for rising threshold */ - ret = tzd->ops->get_trip_temp(tzd, i, &temp); - if (ret) - goto err; - temp /= MCELSIUS; - data->tmu_set_trip_temp(data, i, temp); - /* Write temperature code for falling threshold */ - ret = tzd->ops->get_trip_hyst(tzd, i, &hyst); + struct thermal_trip trip; + + ret = thermal_zone_get_trip(tzd, i, &trip); if (ret) goto err; - hyst /= MCELSIUS; - data->tmu_set_trip_hyst(data, i, temp, hyst); + + data->tmu_set_trip_temp(data, i, trip.temperature / MCELSIUS); + data->tmu_set_trip_hyst(data, i, trip.temperature / MCELSIUS, + trip.hysteresis / MCELSIUS); } data->tmu_clear_irqs(data); @@ -360,21 +349,23 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) } static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data, - int trip, u8 temp) + int trip_id, u8 temp) { - const struct thermal_trip * const trips = - of_thermal_get_trip_points(data->tzd); + struct thermal_trip trip; u8 ref, th_code; - ref = trips[0].temperature / MCELSIUS; + if (thermal_zone_get_trip(data->tzd, 0, &trip)) + return; - if (trip == 0) { + ref = trip.temperature / MCELSIUS; + + if (trip_id == 0) { th_code = temp_to_code(data, ref); writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); } temp -= ref; - writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip * 4); + writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip_id * 4); } /* failing thresholds are not supported on Exynos4210 */ From patchwork Mon Sep 26 14:05:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988743 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 D0730C32771 for ; Mon, 26 Sep 2022 14:07:51 +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:References: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=O9wvLqR9SRMzpM/g0XUQvpEf9e195aL14K53ZPFcsfU=; b=AAuH5ojLYV+qW0 mRLSUlf24VVr/llLLtk2guKB4eAUW8iHw0nJ+excQVPfkiU2YDRL+ku60hvzR7bv7xGRD0T0iMmcu 51PSk9D4mNi5T8yCQLuNLjMK9MXlhYWGb7M92qtuyCC2OhR4oTA19d4h3Er6KDsBAtgpsAANhLNS8 VKnE6ZtWTVm3ZA7WAu8eZQnOy3b5rUSOjtVTrCzGW1q16O0ahDz81eDJNZWs27JKemrtDV+PGIaBa 7K0zzjVv1naIL+TqWHfUOKEO3Vl/CbR5EVLDAPvdD7fg+xExcSw1JF2gwV/FPvquPLLNK9i1RzYg6 6ehSAugW9GgRqKsl8BdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocokq-005Gj7-KU; Mon, 26 Sep 2022 14:06:40 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocokg-005Ggb-Rm for linux-arm-kernel@lists.infradead.org; Mon, 26 Sep 2022 14:06:32 +0000 Received: by mail-wr1-x430.google.com with SMTP id cc5so10412086wrb.6 for ; Mon, 26 Sep 2022 07:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=YVY6NIlG8E5MYLRDa2EiAoJgns8PVyfYKnGRLgZZLm7fx8zerSdtoskRa91POGwnsc KzA+kBKLt/IvYFHVQX08ps11j0X9q90x5cEamJ13yQPAfMurnqQIWWd58GYbKcgYx0+W isVYYTBHM4veXgds5rVH3lxZEoJNNYAMQ1LgAVzVtByqGNZdWAYAirwC8HLF9zZuzLtP l2a0DdiUpyGB/gH1srv75MVg1Ih5UN4STdwOniy7xvHzMzXhAetI3FR9fKZZDXVztbCa WbFrO13ViwlC7GbUSx82BMsKYvoX7fLEnyK5ci9Hp6n+AINetViPxB6qnfsuann3yViD ov7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=poj6Nix+NaeT+PSox4qd4xTCSP3XwfooQcPsX56j6IVgbJzyZ1UWJhdxbKxmLUnL1f BhxVzy+oBaFWAiWyOkW3q7VWYgq3AsyHW+unOCMcbwjWpnOoaeroRgGq4q1SEM34Y4BH 6lRt1ikzYsQipC7QOx7hGw03tYXxFNcSIciFnMqH2xoLmOvE86N5CAxdpRNnx5KEyHhn 7whwZK1RpGXNTWA7Lxf4aBVwr7z2jI9BlG19yb2Vrf19tBjHxOx6pTjirAHNsEWtHlwa UftmNpJMCpGLzK62AnQNoaf3RifDQPMT29Hq4vVRRBpjw+S/ww9QhflVLhrFgawVFqCf dsmA== X-Gm-Message-State: ACrzQf3LI/qCjHNTpyvMCdJwFT7Srgh3yuVC86Pr0doD/fxuxONx+SHT W15Eqc9WdYpq46EnWSDv3pZ5+g== X-Google-Smtp-Source: AMsMyM5veGH4dyYihTWvuy0zbsnz2bzt49D2I3XuR+AiNTbAalnoODS/c84isgnulFd8jc1u1OMlCg== X-Received: by 2002:a05:6000:78e:b0:22a:7e99:da93 with SMTP id bu14-20020a056000078e00b0022a7e99da93mr13503449wrb.20.1664201188818; Mon, 26 Sep 2022 07:06:28 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:28 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v5 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Date: Mon, 26 Sep 2022 16:05:43 +0200 Message-Id: <20220926140604.4173723-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220926_070630_917735_A4C8D8EE X-CRM114-Status: GOOD ( 13.35 ) 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 The thermal core framework allows to get the number of thermal trips, use it instead of visiting the thermal core structure internals. Signed-off-by: Daniel Lezcano Reviewed-by: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 0e33d32a9d2e..91e6860b5ec4 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,6 +260,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tzd = data->tzd; + int num_trips = thermal_zone_get_num_trips(tzd); unsigned int status; int ret = 0, temp; @@ -271,12 +272,12 @@ static int exynos_tmu_initialize(struct platform_device *pdev) goto out; } - if (of_thermal_get_ntrips(tzd) > data->ntrip) { + if (num_trips > data->ntrip) { dev_info(&pdev->dev, "More trip points than supported by this TMU.\n"); dev_info(&pdev->dev, "%d trip points should be configured in polling mode.\n", - (of_thermal_get_ntrips(tzd) - data->ntrip)); + num_trips - data->ntrip); } mutex_lock(&data->lock); @@ -289,7 +290,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ret = -EBUSY; } else { int i, ntrips = - min_t(int, of_thermal_get_ntrips(tzd), data->ntrip); + min_t(int, num_trips, data->ntrip); data->tmu_initialize(pdev); From patchwork Mon Sep 26 14:05:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988744 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 88412C07E9D for ; Mon, 26 Sep 2022 14:07:54 +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:References: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=6dN+3AOO95WL3XVe8Mlfc4M3KJH7NWXmGWuvtu3YSkg=; b=gx26MBu9Ne69z/ jJ9/RGOpXPdZy0c6hRKCpFP4Rsv5Smq2T1DF8108aW6a5wR4uZwdHA6Z2CaCSVYBMSYccUn5/+Rv4 XzWvF4n4vtOn695TBBF59Qt4LtEYgO1n4R8OFHAtLqfcXKo2VQG0RqMH/uURUfOBAcs8Y4HoKkt46 Y24WJ7rMhaQanpy/qKfjMboP7+lQZHhAXFY7X6+3pk7RWvPyjArw9zJD+fTOETWxlhx/IB0ssfv8f 35EEsplHFf9cex8CxhuAQTpB5Wgu/08fpttwtk91k9lC+VMfkRBEwjTz06Th1WQeOkbaALRbKXav0 /dLXLoUzkqqwE2BTUsnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocol0-005GlA-3S; Mon, 26 Sep 2022 14:06:50 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocokh-005Gh0-Rc for linux-arm-kernel@lists.infradead.org; Mon, 26 Sep 2022 14:06:33 +0000 Received: by mail-wm1-x32d.google.com with SMTP id o5so4603350wms.1 for ; Mon, 26 Sep 2022 07:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=7e6ctEATW9s/XP6ppX0yJV3WjnU6tGYDDticrBE+dlY=; b=yXgAz7fHswCIEtOIYeo9cgpLiiJBWfgvR4uHjBK+K3qUYbnA8Y++ovFczH2C2Z7gtU N9C2D/iFJgdiYBdSN8O/VHkxCnNTG45plxKso6KCjXls1Jyot4+M4i82ezxMXH6d7U24 TG2E+oksIjDAputjsIhcsdUgxOX8SKFQYt+8WdKoC13fpMeTX/VQDK/tFu/VJfWdG+ny snjNU2/Xgz7PLDUjyfNwSLF+WOOoiJXEJVo0Qyuky86Wm2qjhG1STdPTdjEUJPIAe/uB hHZqWe/jK0wKdeMATM2ltoobIgkwpjo5Uwra5cIi8i4cE1ARfJYc01OvLEFAW9NF2j5c R1FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=7e6ctEATW9s/XP6ppX0yJV3WjnU6tGYDDticrBE+dlY=; b=ZeSDDXxRdOfv3cQhHQCBYYTbvAv1lNPzzr1YCzpnS18inHCf5EkwawaT0U6MYPcfwl qcJDUB2Qr2vTV2tafh/kKp1+GLjfUiRzGsiCl1/9u1EkhV0ugAeQRpy5XrLvPHUXqdFl ZwPHg1p+NZu7yQ7GuiW2RUgwimhM9rhr9QPT0Dz59QdzpXroOD/1/yPbtIhVuRqQ65Pw CGbuBQWqzdXdEa8BXyYlBjYONK/79uxiTaegNWQISARjwq20To7XCphe2/+QvhQEm8/d ktQ+/xQ+Ojj/rMaOVqbuqqHPMS7DVMbuC/gCtah00vDS4jieq94l7erocxpOhcm9mMIa fUvQ== X-Gm-Message-State: ACrzQf33M/CxrZfLFfJTDUq3MRCUiVdIHOuFhrk15w0Wz/wPrMMit4Ql wNh00jIVcN1X9gDbfkl79ho/Pw== X-Google-Smtp-Source: AMsMyM7TAKm/5G7gkn7KlWPaE8c2DactDCCCu5Mc+JzPmPF6T54v2Ql/KNI5i3Xl9udNqwWnFigHQQ== X-Received: by 2002:a7b:c050:0:b0:3b4:fae1:6bce with SMTP id u16-20020a7bc050000000b003b4fae16bcemr14732183wmc.131.1664201190192; Mon, 26 Sep 2022 07:06:30 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:29 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v5 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Date: Mon, 26 Sep 2022 16:05:44 +0200 Message-Id: <20220926140604.4173723-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220926_070631_912417_5AD33A74 X-CRM114-Status: GOOD ( 13.23 ) 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 The thermal_zone_get_trip() does the same check as of_thermal_is_trip_valid(). Replace the call to of_thermal_is_trip_valid() by thermal_zone_get_trip(). Signed-off-by: Daniel Lezcano --- drivers/thermal/samsung/exynos_tmu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 91e6860b5ec4..34b460092308 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -554,13 +554,14 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en = 0, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { for (i = 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; interrupt_en |= @@ -584,13 +585,14 @@ static void exynos5433_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en = 0, pd_det_en, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { for (i = 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; interrupt_en |= @@ -615,13 +617,14 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en = 0, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { for (i = 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; interrupt_en |= From patchwork Mon Sep 26 14:05:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988745 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 971E9C32771 for ; Mon, 26 Sep 2022 14:08:06 +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:References: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=78F2AfKVLdhe780bioU2XER+/Bp346Ozc5UfLQJ1tlo=; b=MW7ll4wQ1Cm+8+ W2vz6M3NSxGHiK7sXQjVn4bdlzfa9PktptP3IrGF2Z/ZdfSaCwLTNJZTZ36C553uBly6Z4EGAUHeC 9sugk1YPI4iTDlRyz8TrsMcQL5FmSTm7+rr3mrq6X16uQStbGWYyr7zswmTYLtPXC+gIQGuTd63Bh MjNempc44Qi5ne/XZpOEeHGKHbY5BWyZ4Ntvx1R3G2GFj8Gtau7BpvKetpaFY2DHpgKOGE3rh8fgA AmLdwsJYNlJV5kkQt2sjx8rKNGdZOfXEGeAD3kzbjrUZ5nA7xGu3FR8+XGvoAprDhxfaqRkeWFJnA CWyyWfG2x2ow0VTU0gEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocolB-005Goc-0U; Mon, 26 Sep 2022 14:07:01 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocokl-005Ghy-Na for linux-arm-kernel@lists.infradead.org; Mon, 26 Sep 2022 14:06:37 +0000 Received: by mail-wm1-x32f.google.com with SMTP id u16-20020a05600c211000b003b5152ebf09so5018529wml.5 for ; Mon, 26 Sep 2022 07:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=sqO/O1aFXJtFOKef2CLDy2KKoGo8mS1jDc0v38LlO4RsfpXxavOpN1TxtCAobC4yO3 kNv2B00br95zTYjJS9brJ+w5p6aI1B2nSj1JtpnHAoQqcKTO+B3NZht/kub2MfdwOxet Evm4oMZyp6uCsSlcx+dSf7ZvAADUW2jSacn8Y74kT7yhK8gG5sL92VCKetIy/uef5lNI 0MkUVZCHihEcwswFI6nNmpVOJ8Ke0AgMDB+K5q3xHGBwtIYohPQtlDZg1/kDkpndeiVw Jhih4H1DDmdVMIr+2pSA9TCh9m1wGYQGKyVGAJiAsyXkbcBmaVWQoPmZJb0sZA/2SvDE b/KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=0otTHIRIBGxdZYk7vpLikGSmj1xk6g96IH2uy5MKhH8FPSX00gby3uKmvcGysuazwH S7mJ346X1uQunTbrRIvX+ZNMhNTGG/kO4BulEEJykm6Ohe/8dw8aQ20IoZxii518dNOw YTjKqJ63RSSJ3mfuFF6RaOBtVYDk4nW4rQptL/5TgbtUdQxw46n83xyPc9uepZBOm3S5 +sRKNqrEhrYNHx5sBiigJoemEFic1HF4gvCuT1aK25y4Qnh+m0ev49zrxr5oQWZzYIHL Ylj+GnCVUfro2BdnfP7UEbrsYg5amcWlacHLH3++clslTx6QCyMRz2zoTMrWmBO8/qHM tVVw== X-Gm-Message-State: ACrzQf0wcYLZRrM6J1VQpUxEBYGEimJM0EXpCpqNiteQbvXf828aLEVP tYbvpk7P4M9X7EDaulxNAv5CDQ== X-Google-Smtp-Source: AMsMyM6HXTifdgRuNXtogg59dwFlxvk/9EzRjUIZBwKpxkvtUZNRBVRRWpFOp6S2LnET4G2WYaRKQw== X-Received: by 2002:a7b:cbc4:0:b0:3b4:fd67:d70d with SMTP id n4-20020a7bcbc4000000b003b4fd67d70dmr16957755wmi.98.1664201193975; Mon, 26 Sep 2022 07:06:33 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:33 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Kunihiko Hayashi , Amit Kucheria , Masami Hiramatsu , linux-arm-kernel@lists.infradead.org (moderated list:ARM/UNIPHIER ARCHITECTURE) Subject: [PATCH v5 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:46 +0200 Message-Id: <20220926140604.4173723-13-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220926_070635_790735_7A85BEEA X-CRM114-Status: GOOD ( 14.24 ) 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 The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Kunihiko Hayashi --- drivers/thermal/uniphier_thermal.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_thermal.c index 4111d99ef50e..277ae300c5b1 100644 --- a/drivers/thermal/uniphier_thermal.c +++ b/drivers/thermal/uniphier_thermal.c @@ -248,8 +248,7 @@ static int uniphier_tm_probe(struct platform_device *pdev) struct regmap *regmap; struct device_node *parent; struct uniphier_tm_dev *tdev; - const struct thermal_trip *trips; - int i, ret, irq, ntrips, crit_temp = INT_MAX; + int i, ret, irq, crit_temp = INT_MAX; tdev = devm_kzalloc(dev, sizeof(*tdev), GFP_KERNEL); if (!tdev) @@ -296,20 +295,18 @@ static int uniphier_tm_probe(struct platform_device *pdev) return PTR_ERR(tdev->tz_dev); } - /* get trip points */ - trips = of_thermal_get_trip_points(tdev->tz_dev); - ntrips = of_thermal_get_ntrips(tdev->tz_dev); - if (ntrips > ALERT_CH_NUM) { - dev_err(dev, "thermal zone has too many trips\n"); - return -E2BIG; - } - /* set alert temperatures */ - for (i = 0; i < ntrips; i++) { - if (trips[i].type == THERMAL_TRIP_CRITICAL && - trips[i].temperature < crit_temp) - crit_temp = trips[i].temperature; - uniphier_tm_set_alert(tdev, i, trips[i].temperature); + for (i = 0; i < thermal_zone_get_num_trips(tdev->tz_dev); i++) { + struct thermal_trip trip; + + ret = thermal_zone_get_trip(tdev->tz_dev, i, &trip); + if (ret) + return ret; + + if (trip.type == THERMAL_TRIP_CRITICAL && + trip.temperature < crit_temp) + crit_temp = trip.temperature; + uniphier_tm_set_alert(tdev, i, trip.temperature); tdev->alert_en[i] = true; } if (crit_temp > CRITICAL_TEMP_LIMIT) { From patchwork Mon Sep 26 14:05:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988746 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 AF94CC32771 for ; Mon, 26 Sep 2022 14:08:31 +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:References: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=rC7VzmfyDg/a3jsZFMqHdzRbAMSkSiO4XK0b52m8aL0=; b=nhp7mdboSR8arO yjFNlzcDdH9JYvFgUySY80p9gSQE7jMaQPeBgrT34lhg8zGsH3mA2pPMiM3nQCIcO+7mQxpm0VLer cOc73zonpH+GrtTIv4eOugVRNSiIpUW5Vh/Pn48soFb99qGfomut68OaZSy4g5u0zNm/poDL4fScE kcKh/S3y4uwt6Fm1hKC/Q3nQnY1s/QEe/xaOyaplj63bBH5t+MpB6Z5G05ykdPVRF2Pgu8yPaIy/7 h2eAQZmYQ7HZSPMJuUuX7etrlo879QPwltyhp9Iq4vJt7yGPXHFNANAS9I+fG5EvlO4WTILq37qEv VcoaGJzriqxFA0Xi59NA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocolO-005Gt0-M6; Mon, 26 Sep 2022 14:07:15 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocol1-005GlH-6n for linux-arm-kernel@lists.infradead.org; Mon, 26 Sep 2022 14:06:53 +0000 Received: by mail-wm1-x32b.google.com with SMTP id r133-20020a1c448b000000b003b494ffc00bso7605736wma.0 for ; Mon, 26 Sep 2022 07:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=liAY8kSwesGP7MaoIOTZ0IAN4Zvdt1iNYHsul5rTsE5mLrMsDXWx/ix7SCWx/J4hf5 4AySUU//BfnXeu2vZcGG9pC2zZLY5eApN/QwONGLz6USScpIbYoSBLgZJ0G3NH/f1pk5 s+MyzQio66riivkHY6CO8TkU7GVr4/ojTP1OBNCwmGoyUQbq0dBWfNcTaV3qIMoIpGYe MrtvJ47R2q/GJPEInGnCuLu3CtprwCF0srNOtgP3IxSqulfAtqFfNocH2U3Efss13L3F 7xbI/SqYqKkt/4E7ZAkHdqX7m4sL0ueBQlABUY1UCQnxpRevmKHL+25gOzjgGVj5KZHD cCRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=nL67Ut/tm7OSD8jQVifwhjORwFTOEzn3s1h7tnf2PFdEgiT3T+8ShXXGB2OuyTjwbQ RnL8TF85hH2iWGEHfmGnAWjrrl5jVJdx2OZTRK+UP8iywPPID1PtIkQ7Tae/rqglpBCD D6yi3ch/mz/74wVTTvIOt63v7X2ysuEX5qKgLkSB+/YWcZu3cVca5FUzGcZu8KELstjo D5r4I+xEVu7Dj+7aETPvX8jqJu+p8HSrNti0l2LbOeja3nP+v6+nQqHp1pSffnwO1BbO ABItBp32C4VZcVO+aWQcCs5O2uIIYDPy+kQFcKy/wxTW4Zi/U1xkOUGavY30ZMhSTTYb BCow== X-Gm-Message-State: ACrzQf3NutEBHGHVd9EAIRtLnOY3BFgqsgeiy/EJ4eUPAR2UcEPgbAb+ 0ssb+96FByvf/ZsPrYiWlsoe0A== X-Google-Smtp-Source: AMsMyM4pLzup1JiIdIX2dTkpa05sv5SO7a4FV3of23FpqW+uHfHa2p2IS87RxHo3MO3PI/jvWGdumQ== X-Received: by 2002:a05:600c:24c:b0:3b4:fa20:6f6b with SMTP id 12-20020a05600c024c00b003b4fa206f6bmr15494737wmj.14.1664201209466; Mon, 26 Sep 2022 07:06:49 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:48 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE) Subject: [PATCH v5 22/30] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:56 +0200 Message-Id: <20220926140604.4173723-23-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220926_070651_292436_EB22D97B X-CRM114-Status: GOOD ( 18.30 ) 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 The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/imx_thermal.c | 72 +++++++++++++---------------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 16663373b682..fb0d5cab70af 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -76,7 +76,6 @@ enum imx_thermal_trip { IMX_TRIP_PASSIVE, IMX_TRIP_CRITICAL, - IMX_TRIP_NUM, }; #define IMX_POLLING_DELAY 2000 /* millisecond */ @@ -115,6 +114,11 @@ struct thermal_soc_data { u32 low_alarm_shift; }; +static struct thermal_trip trips[] = { + [IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE }, + [IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL }, +}; + static struct thermal_soc_data thermal_imx6q_data = { .version = TEMPMON_IMX6Q, @@ -201,8 +205,6 @@ struct imx_thermal_data { struct thermal_cooling_device *cdev; struct regmap *tempmon; u32 c1, c2; /* See formula in imx_init_calib() */ - int temp_passive; - int temp_critical; int temp_max; int alarm_temp; int last_temp; @@ -279,12 +281,12 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp) /* Update alarm value to next higher trip point for TEMPMON_IMX6Q */ if (data->socdata->version == TEMPMON_IMX6Q) { - if (data->alarm_temp == data->temp_passive && - *temp >= data->temp_passive) - imx_set_alarm_temp(data, data->temp_critical); - if (data->alarm_temp == data->temp_critical && - *temp < data->temp_passive) { - imx_set_alarm_temp(data, data->temp_passive); + if (data->alarm_temp == trips[IMX_TRIP_PASSIVE].temperature && + *temp >= trips[IMX_TRIP_PASSIVE].temperature) + imx_set_alarm_temp(data, trips[IMX_TRIP_CRITICAL].temperature); + if (data->alarm_temp == trips[IMX_TRIP_CRITICAL].temperature && + *temp < trips[IMX_TRIP_PASSIVE].temperature) { + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); dev_dbg(&tz->device, "thermal alarm off: T < %d\n", data->alarm_temp / 1000); } @@ -330,29 +332,10 @@ static int imx_change_mode(struct thermal_zone_device *tz, return 0; } -static int imx_get_trip_type(struct thermal_zone_device *tz, int trip, - enum thermal_trip_type *type) -{ - *type = (trip == IMX_TRIP_PASSIVE) ? THERMAL_TRIP_PASSIVE : - THERMAL_TRIP_CRITICAL; - return 0; -} - static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct imx_thermal_data *data = tz->devdata; - - *temp = data->temp_critical; - return 0; -} - -static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, - int *temp) -{ - struct imx_thermal_data *data = tz->devdata; + *temp = trips[IMX_TRIP_CRITICAL].temperature; - *temp = (trip == IMX_TRIP_PASSIVE) ? data->temp_passive : - data->temp_critical; return 0; } @@ -371,10 +354,10 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, return -EPERM; /* do not allow passive to be set higher than critical */ - if (temp < 0 || temp > data->temp_critical) + if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) return -EINVAL; - data->temp_passive = temp; + trips[IMX_TRIP_PASSIVE].temperature = temp; imx_set_alarm_temp(data, temp); @@ -423,8 +406,6 @@ static struct thermal_zone_device_ops imx_tz_ops = { .unbind = imx_unbind, .get_temp = imx_get_temp, .change_mode = imx_change_mode, - .get_trip_type = imx_get_trip_type, - .get_trip_temp = imx_get_trip_temp, .get_crit_temp = imx_get_crit_temp, .set_trip_temp = imx_set_trip_temp, }; @@ -507,8 +488,8 @@ static void imx_init_temp_grade(struct platform_device *pdev, u32 ocotp_mem0) * Set the critical trip point at 5 °C under max * Set the passive trip point at 10 °C under max (changeable via sysfs) */ - data->temp_critical = data->temp_max - (1000 * 5); - data->temp_passive = data->temp_max - (1000 * 10); + trips[IMX_TRIP_PASSIVE].temperature = data->temp_max - (1000 * 10); + trips[IMX_TRIP_CRITICAL].temperature = data->temp_max - (1000 * 5); } static int imx_init_from_tempmon_data(struct platform_device *pdev) @@ -743,12 +724,13 @@ static int imx_thermal_probe(struct platform_device *pdev) goto legacy_cleanup; } - data->tz = thermal_zone_device_register("imx_thermal_zone", - IMX_TRIP_NUM, - BIT(IMX_TRIP_PASSIVE), data, - &imx_tz_ops, NULL, - IMX_PASSIVE_DELAY, - IMX_POLLING_DELAY); + data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone", + trips, + ARRAY_SIZE(trips), + BIT(IMX_TRIP_PASSIVE), data, + &imx_tz_ops, NULL, + IMX_PASSIVE_DELAY, + IMX_POLLING_DELAY); if (IS_ERR(data->tz)) { ret = PTR_ERR(data->tz); dev_err(&pdev->dev, @@ -758,8 +740,8 @@ static int imx_thermal_probe(struct platform_device *pdev) dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC" " critical:%dC passive:%dC\n", data->temp_grade, - data->temp_max / 1000, data->temp_critical / 1000, - data->temp_passive / 1000); + data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000, + trips[IMX_TRIP_PASSIVE].temperature / 1000); /* Enable measurements at ~ 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR, @@ -767,10 +749,10 @@ static int imx_thermal_probe(struct platform_device *pdev) measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_SET, measure_freq << data->socdata->measure_freq_shift); - imx_set_alarm_temp(data, data->temp_passive); + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); if (data->socdata->version == TEMPMON_IMX6SX) - imx_set_panic_temp(data, data->temp_critical); + imx_set_panic_temp(data, trips[IMX_TRIP_CRITICAL].temperature); regmap_write(map, data->socdata->sensor_ctrl + REG_CLR, data->socdata->power_down_mask); From patchwork Mon Sep 26 14:05:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12988747 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 4EF75C32771 for ; Mon, 26 Sep 2022 14:09:05 +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:References: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=mMjKODOPuxNSMHRx6sLDPA7/X4hPA9FdN7Okm/tRvOo=; b=WynC9eUS/ZBTgS 9BhqsNNSW+pjJeZ8c/LHJBulaUSO9omxK0nDWzIHA2WSzJaU6S579L7EheoApy5jYvVPdRzg1i1uC 78wJ2246U4Rb0SGbz+DROF5YuvoDHiLNUx8dp13IfXbgK9OZ75cam74tvfsDwNPqGaWcVy+Z+Qpu6 LL8hqhCfJKNaXGKjL+yZOfj8b1wMbFpd/FbFTFA3nLNzNMad746t+UEgzi/RdrHe+wqaSyv4q2wuO yLqB5MLcXOep34kQvBzyn0Ea83vFQeeTjEvpDXsalluvc6Bcjw8cElYXolAF8yMe2XcDo7xY97xw1 661BJ5yaqTzzz6RIe7YQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocolp-005H3q-4D; Mon, 26 Sep 2022 14:07:41 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocol9-005GmX-JF for linux-arm-kernel@lists.infradead.org; Mon, 26 Sep 2022 14:07:00 +0000 Received: by mail-wm1-x332.google.com with SMTP id i203-20020a1c3bd4000000b003b3df9a5ecbso7585646wma.1 for ; Mon, 26 Sep 2022 07:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=T+qYO3llwUwso32BkYS1kv3SBonRyZ9HsFQWCOev8fDPELdQc56lwcRjbNa63bPjsJ AaK79jaNovAimi7tlaHVhvniTBHRV7hW+FOu/EH8GGJxIzm065Bpps4tFmlkiglF1UyJ RnQ3bbwNQ63gu6tEXBSnBfG8Py9YJIG3Dcl/YjXeLnBvraZGS5nXDqDrpQEho5uBlrjt xqWiHi+aqbEOkvMk15ibG+u4pIZ2zH2B863kKw+d1p9a9uC+MMkm8zfiw4qY3EkLRqXv nwrLU3IZNbo00BYmLVBQaCM+zUNbvGoV/Av6zNt0VbpME2DMw6Lg9Pd4jJWulb6djHL+ tKqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=zIUtJz/kXQjIhGfmDzLh+nbEevGE+/ew29B6xArLjq1wR4R8xjNEI3wfyj1Qhxpzu/ hoDEUiT+nLh/v1jtoaO+fOJXriTy1xFYxmci4oI7CJCMSJbINtR7id+T+E9Y+ikun1Js 1AvvPpSwxMZxJbkZQVXrixXnN9iK0TjAnclLhg7s2zSgH5e6hXIDMpo3o9DyKHdO5iRp 64OWwIB9VxGKznDMiM0x9rFqB4z5HdQQDH8LKarOV0XinXFwJaL+7hRLG5exEPOMeGAU vu7lotW2P6GJVHdIWtM5hmQt4Gifsa3mUMlgkjchS1fZzhz6FTNAr+YnSaCzmGCbx0lA Nopg== X-Gm-Message-State: ACrzQf0w6Qu/TPOSu82gWd1vaFljOK71GsEaqgG0/6/2jeOd3BP46z1G bMW7VexCf+TAE2DB870uMwDphw== X-Google-Smtp-Source: AMsMyM7KmIDtVH4wXUQBQWMer4IDmi6aj2W1A3NPf9b5sqTNvsh7yYTzc41bHp9m8L4yiccyBTvqTA== X-Received: by 2002:a7b:cb41:0:b0:3b3:34d6:189f with SMTP id v1-20020a7bcb41000000b003b334d6189fmr22308524wmj.6.1664201213772; Mon, 26 Sep 2022 07:06:53 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:52 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE) Subject: [PATCH v5 24/30] thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:58 +0200 Message-Id: <20220926140604.4173723-25-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220926_070659_640783_66B33829 X-CRM114-Status: GOOD ( 14.85 ) 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 The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/broadcom/bcm2835_thermal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c index 2c67841a1115..5485e59d03a9 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -18,6 +18,7 @@ #include #include +#include "../thermal_core.h" #include "../thermal_hwmon.h" #define BCM2835_TS_TSENSCTL 0x00 @@ -224,7 +225,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) */ val = readl(data->regs + BCM2835_TS_TSENSCTL); if (!(val & BCM2835_TS_TSENSCTL_RSTB)) { - int trip_temp, offset, slope; + struct thermal_trip trip; + int offset, slope; slope = thermal_zone_get_slope(tz); offset = thermal_zone_get_offset(tz); @@ -232,7 +234,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) * For now we deal only with critical, otherwise * would need to iterate */ - err = tz->ops->get_trip_temp(tz, 0, &trip_temp); + err = thermal_zone_get_trip(tz, 0, &trip); if (err < 0) { dev_err(&pdev->dev, "Not able to read trip_temp: %d\n", @@ -249,7 +251,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) val |= (0xFE << BCM2835_TS_TSENSCTL_RSTDELAY_SHIFT); /* trip_adc value from info */ - val |= bcm2835_thermal_temp2adc(trip_temp, + val |= bcm2835_thermal_temp2adc(trip.temperature, offset, slope) << BCM2835_TS_TSENSCTL_THOLD_SHIFT;