From patchwork Wed Mar 8 21:48:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 661421 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 5781CC64EC4 for ; Wed, 8 Mar 2023 21:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbjCHVs6 (ORCPT ); Wed, 8 Mar 2023 16:48:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbjCHVs4 (ORCPT ); Wed, 8 Mar 2023 16:48:56 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32CEE99D51 for ; Wed, 8 Mar 2023 13:48:40 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id h14so33025wru.4 for ; Wed, 08 Mar 2023 13:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678312118; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9b973OIjh2A0q4it2tRxdKfeAcI3pT5uZD5jTJWInpI=; b=YMAZmJORveNcNQt8Xuwzh04+SXOMfA0xiAPvb6CaAqKSZGmF0QwHOHB2Qmu1jT1yxQ Y4WWPCF9Nj+IS21dbGu7Hh1bRdn5iwZJTGmgxGn7OfVXfTLVjaCxt0puIxF/msRd9np4 pgszGCaIjfQCdHQDxsxpzWwcopep3sj7QnEz6xk0unVb+rg3gKtoWSh4Vm8cNuqPDGae vR1lm6gamA6AnRxa+PiJ/QrI1Hd4fA7PifMMitRNmRPWjXnALM8Mp9FQBVCeMe/af4L3 8Y/FDU9hCDAOqDc61m5MYZugAa9DLbj1B4t696f0Pyx3K7WoL+OZUWBm7d/Lhky4Nhjw ms4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678312118; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9b973OIjh2A0q4it2tRxdKfeAcI3pT5uZD5jTJWInpI=; b=54GWQBEOguTzbpOlKwx1WxyUvD4EAx7ZydNwI63Fc7RKtpUU7H8PuqLsKjQ3tPDlEe JejJPoMMSLEUrvWhdt2ZpJe7mzQkLZ76QMkOPgsMGBYJX3y0G/t+cFOuQVcC06yJmKr9 BcArVbz+Zeme5StsBXUcTkNESv+vCIsHxA1Xd9fQo/j/pSH3/tJCjXV2ey4HznPYpHEv YR3fBhSNBCMKmQBOpaICKEmUUgzyQXEVDN9UEuN0Q+2ucx2qh+5nTIJToXXvwleJuhuI jhGhHAMn5ms5hiUFblYTe4c9rq9ylTZDo8C6lGLO6CB4k3++FzzgOQMaPMC8VrYE+mx5 wfzw== X-Gm-Message-State: AO0yUKVfGI/1QnDEiaiPcL0e+q17jimn8Wh7aFc1AZ1wV3HVjv/1vW/4 OBLcbhOUSzvi/dS2nGlHAeHSHw== X-Google-Smtp-Source: AK7set9dNQIoqJwJ1YDp+pOXC2yzZe8SPtUpY47j+15NDVfKGPTAxNPVDJYhNaO50DjaF0ITnaNgKQ== X-Received: by 2002:a5d:62c3:0:b0:2c5:5237:3b21 with SMTP id o3-20020a5d62c3000000b002c552373b21mr13902966wrv.69.1678312118499; Wed, 08 Mar 2023 13:48:38 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:fbda:65f5:e873:7527]) by smtp.gmail.com with ESMTPSA id z6-20020adfd0c6000000b002c55efa9cbesm16065713wrh.39.2023.03.08.13.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 13:48:38 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui , 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 1/2] thermal/drivers/imx: Remove get_trip_temp ops Date: Wed, 8 Mar 2023 22:48:21 +0100 Message-Id: <20230308214822.1317086-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The i.MX thermal sensor uses the generic trip points. The thermal framework can return the critical temperature directly. Remove the pointless get_trip_temp ops. Signed-off-by: Daniel Lezcano --- drivers/thermal/imx_thermal.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index c3136978adee..69ed482167f7 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -330,13 +330,6 @@ static int imx_change_mode(struct thermal_zone_device *tz, return 0; } -static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) -{ - *temp = trips[IMX_TRIP_CRITICAL].temperature; - - return 0; -} - static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp) { @@ -384,7 +377,6 @@ static struct thermal_zone_device_ops imx_tz_ops = { .unbind = imx_unbind, .get_temp = imx_get_temp, .change_mode = imx_change_mode, - .get_crit_temp = imx_get_crit_temp, .set_trip_temp = imx_set_trip_temp, }; From patchwork Wed Mar 8 21:48:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 660869 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 AB576C6FD19 for ; Wed, 8 Mar 2023 21:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbjCHVs7 (ORCPT ); Wed, 8 Mar 2023 16:48:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230133AbjCHVs4 (ORCPT ); Wed, 8 Mar 2023 16:48:56 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD4889F2C for ; Wed, 8 Mar 2023 13:48:41 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id h14so33054wru.4 for ; Wed, 08 Mar 2023 13:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678312120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bSi6Beth8Hd606NS4V715NDwa0mm95xS/EhiukW+s4A=; b=s6QYhBdP4xz1DCwwEoxAGKi1ZWo634kvMmuIClnvYe1bD7KyDs4Pt+l2UGtPZaHKWX sYfJSWEk4DSD6oQMZTxMdn9TkZ97eARWubG7zg/JIxCAa3Q9/2aCRZ7E5qoNBClSnNvb plkJISAvvYC2DYpTm1dMEOG21vnT2p8VeVDSK+0TRWDSzy6pzofQmDhwK8+DMs1Y4Sda 7rUNdsF2BXDNxe/MBCxV9cvN0fqFIt6b+88U3WLzPo/g0UWdhyNfV7eWtk7FVHOiVbFy 8mtL4imBVP0o3acwsFIGlyKSp3nqP2X26+VTLiOPg5UKxgw7BPiy1DIG9sOvzI62JazG blRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678312120; 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:message-id:reply-to; bh=bSi6Beth8Hd606NS4V715NDwa0mm95xS/EhiukW+s4A=; b=H9Op8RZKuFBrbmtVoo8OiVLMKfPFhpH7/8NlZqDCEfSHv0eyQyYAJeYcknUOlqe+w2 p6jRpQ2IDIP1CVHQ/I/LkP+/6yba2npanEzXyLPFW6kvbPEF/+2GSCNdFE+JfMAGojk1 tfZtabuTllgDi7MxZSma7+ZFMMNR0Ha7zK+zayzd8VI7jk3b/PbvIb+b6TcXM7RrNFMa Y3P530ZPeigMGWo0asFcGKvb43V3iGiZNDqciREfi0TjfG6gkE7w9SCMtf3fid657xcF Js47E6AjHfkPGH5uxJSFZ2fTPA70ZNQaLGOvG3elG0sw1eye9TXcX2kFjc+gdtuXS+6R YjFQ== X-Gm-Message-State: AO0yUKX43WNFH7QdFfHcNG6ffj877UMfbAN3rTD2iGb/tDs7GK4/BiF8 s46qKioZ/0e3ry2qDGVDhV9fdfaxV37F/3z9uGs= X-Google-Smtp-Source: AK7set9vuN8INCmFZBDldnjaZzya3b21KVx/xTSSssDzxqlXf8GDST84z4Er4IgIf1dKoCZy3qx6pw== X-Received: by 2002:adf:df8f:0:b0:2c8:dc8f:3951 with SMTP id z15-20020adfdf8f000000b002c8dc8f3951mr12301392wrl.5.1678312119704; Wed, 08 Mar 2023 13:48:39 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:fbda:65f5:e873:7527]) by smtp.gmail.com with ESMTPSA id z6-20020adfd0c6000000b002c55efa9cbesm16065713wrh.39.2023.03.08.13.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 13:48:39 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui , 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 2/2] thermal/drivers/imx: Use the thermal framework for the trip point Date: Wed, 8 Mar 2023 22:48:22 +0100 Message-Id: <20230308214822.1317086-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308214822.1317086-1-daniel.lezcano@linaro.org> References: <20230308214822.1317086-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The thermal framework provides an API to get the trip related to a trip point id. We want to consolidate the generic trip points code, thus preventing the different drivers to deal with the trip points after they registered them. The set_trip_temp ops will be changed regarding the above changes but first we need to rework a bit the different implementation in the drivers. The goal is to prevent using the trip id but use a trip point passed as parameter which will contain all the needed information. As we don't have the trip point passed as parameter yet, we get the trip point using the generic trip thermal framewrok APIs and use it to take exactly the same decisions. The difference with this change and the previous code is from where we get the thermal trip point (which is the same). No functional change intended. Signed-off-by: Daniel Lezcano --- drivers/thermal/imx_thermal.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 69ed482167f7..e4e82bdf34f1 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -330,26 +330,29 @@ static int imx_change_mode(struct thermal_zone_device *tz, return 0; } -static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, +static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp) { struct imx_thermal_data *data = thermal_zone_device_priv(tz); + struct thermal_trip trip; int ret; ret = pm_runtime_resume_and_get(data->dev); if (ret < 0) return ret; + ret = __thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) + return ret; + /* do not allow changing critical threshold */ - if (trip == IMX_TRIP_CRITICAL) + if (trip.type == THERMAL_TRIP_CRITICAL) return -EPERM; - + /* do not allow passive to be set higher than critical */ if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) return -EINVAL; - trips[IMX_TRIP_PASSIVE].temperature = temp; - imx_set_alarm_temp(data, temp); pm_runtime_put(data->dev);