From patchwork Tue Jan 24 13:50:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 13114186 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 99640C38142 for ; Tue, 24 Jan 2023 14:05:38 +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=/565xkxtQfbUJG4hw6+EMHsrkq5nQw4HER/z8rTnpbw=; b=If+L+7FB4trCD2 HdoL6smDfBYl/AA0l39pGuOIOzxzXqUJReHCcm0v/4nQG/cZ39ErgdWHRT0F8o9z+X2YIbvPs6vjD bC8sPgvoSiCVQgZy6iNDH+8H+eM6wVcnrnalArdrvOO3Bz5TwsLPQz1+CZvUONKfkUSg2G3EHBFPb YliO075/ByFW0Brl47iaz1qO5Xt6041ITO1pVpf8KKrQBSGJPzVM5SiH2+MWxi+cONzU2iOSsy+IJ uaaTbwQbImXo/M18hkVuG0Gr8285TXw6PKkAwoAay25U1+4K/4juCYpfIG/TdhwCBBsQelEsrGwJg BqtDTS9tqB+ug5m0vg1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKJuS-004BG1-0Z; Tue, 24 Jan 2023 14:04:24 +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 1pKJhC-0045AR-Ha for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 13:50:44 +0000 Received: by mail-wm1-x32f.google.com with SMTP id l8so11483794wms.3 for ; Tue, 24 Jan 2023 05:50:39 -0800 (PST) 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 :message-id:reply-to; bh=GRHFm87xhd5kwGJXeGjCaI1s3MvLoDnYqaOChsF1PF4=; b=pcMpDVisDmB6BmL5C0d/5YIhuoNLTKnu81ssrjpVi0NxvZeV70feTYjhtHR4OR/Yyj AwPFghZLg62VGxxiOUpfY7NS1BPAt/GRPfoOKIRmx9ShUf23BuRt5P1BeJyVtxvdxcH6 jxC2OAt0Vm7SvRJ3wiPKXkFfza17Jao1XQOTCyW1zV+ZVsTzyFPxCasrr7dmtJ8RpXPG J/knhYjAVj6EnNl8p+OYpANuWLsuF4BA07CAE3yMxmRXyKF8Gby4YOuu33Z4W4tuhm4o BAhKUwIe5/QnVmRVOaM17TTW5hPKXw0lDZuxZ6iaRVBaV+DuBhLIuAduTNIo14KKpXAq Wp8g== 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:message-id:reply-to; bh=GRHFm87xhd5kwGJXeGjCaI1s3MvLoDnYqaOChsF1PF4=; b=2j65oQT23gL4bWys1iLY5CZUbElhVPhtJhpXx4p7DFtOEygdMogwCeIITgyEvh8BhT IKoDamht/QGXcAevA434ayG0gXMyWM0n/20pJCo74KiXIyNDrU6IKqTvwQBR7Mc6KawJ jYa10QqEOUSjatw/BaSrX9klx/7v4RzqgcA6JZJq/Z+nv5vv9ghdAvCqn3fCWAumxhRQ WrgRAIrLVIZzc57M7XRGPkkSUf1UjyJwt+uEqGG9IR3BPR8t+d5EnpIDl2lhDhyoaoBo oZNTPbiJOv3ftc+2Ywfib6QowgXtc48Z9r1qNpKi+WzphV0yC7A49LAg2dcHXRfL58MQ CKVw== X-Gm-Message-State: AFqh2kqSLSJbYd3XqK4Te0osid2PifTwpxyUgevxm9FhFp7g+ZKQKTsb oR4Sw5Uebb+/o1LhQHZ+HW2Zgg== X-Google-Smtp-Source: AMrXdXspSwahLg1rfkDFtbVlcIe2CrdGVsZjEtpwfCh/Em01sMTR36gIlCx8fYTo8dsT5IjWqMeYXg== X-Received: by 2002:a05:600c:5114:b0:3db:254e:59a9 with SMTP id o20-20020a05600c511400b003db254e59a9mr19030478wms.15.1674568238494; Tue, 24 Jan 2023 05:50:38 -0800 (PST) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id j4-20020a05600c42c400b003db1ca20170sm1972507wme.37.2023.01.24.05.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:50: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 3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check Date: Tue, 24 Jan 2023 14:50:23 +0100 Message-Id: <20230124135024.366486-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124135024.366486-1-daniel.lezcano@linaro.org> References: <20230124135024.366486-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-20230124_055042_693116_4849F38D X-CRM114-Status: GOOD ( 17.12 ) 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 is reworked to use a generic trip point description. That will consolidate the code and will allow to fix a mishandling of the trip points crossed events. In order self-encapsulate the thermal framework and prevent assumption about the indexes we remove the trip id usage in the back end drivers. As the i.MX driver is using the thermal trip generic structure, we can rely on the thermal framework to get the critical temperature instead of using the harcoded IMX_TRIP_CRITICAL index. Signed-off-by: Daniel Lezcano --- drivers/thermal/imx_thermal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index c115a696e83f..10ebf42f4915 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -337,7 +337,7 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id, { struct imx_thermal_data *data = tz->devdata; struct thermal_trip trip; - int ret; + int crit_temp, ret; ret = pm_runtime_resume_and_get(data->dev); if (ret < 0) @@ -347,12 +347,16 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id, if (ret) return ret; + if (temp < 0) + return -EINVAL; + /* do not allow changing critical threshold */ 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) + ret = thermal_zone_get_crit_temp(tz, &crit_temp); + if (!ret && (crit_temp < temp)) return -EINVAL; imx_set_alarm_temp(data, temp);