From mboxrd@z Thu Jan 1 00:00:00 1970 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 63757C38142 for ; Tue, 24 Jan 2023 13:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233161AbjAXNxy (ORCPT ); Tue, 24 Jan 2023 08:53:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234671AbjAXNx3 (ORCPT ); Tue, 24 Jan 2023 08:53:29 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824E34957A for ; Tue, 24 Jan 2023 05:51:23 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id f12-20020a7bc8cc000000b003daf6b2f9b9so12859233wml.3 for ; Tue, 24 Jan 2023 05:51:23 -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=7KeFsLzGCqHOmLoq3WaiVqhzSWU0bcZhMSI7GPr+4hM=; b=kiPlOFixsP6261tglxcomRwMECun5vCh3UCI9DA5wkN0ooI8SqUUURqeyQJs2RtI/t r3JwBy678qo4rOFmyog+Os1f8DbELQYZBlBkbCUikbnaAGwxhVs0DodpIxj6ku3mv2lZ d3f+QR/d/AGRfNkjo8ivadBLxcXHn2kiUrsskJfCbCjLmmAsrDLiWYrOl/OyVf+3bP0Y Av833Q9KawSnvsgdSHJk1Fs5iJg05ciW7jeAqAC/rgQKNQVVPY/MHx6SMoHk3UfWAaTm mmA/aRHv31o8VbAR7phtlYCLQ46YEboe+PcDt3SgaNGJEkttwLWgvKTZ+jDzP7zQOCMC 4avA== 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=7KeFsLzGCqHOmLoq3WaiVqhzSWU0bcZhMSI7GPr+4hM=; b=Kzv5+HsLMRZeiH0Ko7cyQHxHBHoo4pKYqXEKqDY+ilz7OnSJ9/enX4sDYzNtYrHZjG tssxZvGFGFIlwAf183HEv6PzGj8ud41QdlivFJDnsRdTxG3ME1brfm5WXAptinkL1y/e FjQXzd4zo6viwo4Z+EusQOiL/kGp5/6kpShmAxkiOKREaL7waqOy9MEVy1Viy9Tmh1ND JDi5m1sVRTnh8w5PNnmL6rnMbV5yhmXv4wIgMC5Y/cLfsfuH7MpaaLoyg7xhcNWoF1Mh iv9ZRxFS0Xs61rRydahzlE8tgUMUpEFBNo5bVdQ6vuoOEAkcjB7xUlpktgfSVC1CaN9q karw== X-Gm-Message-State: AFqh2kqMWMJD9XR8rm7kKqMARiXSe1cZZmXFIJUCIpgNQi4z7bbgvXEG CIk8980GDJwyW2tz0+0vCwMhQg== X-Google-Smtp-Source: AMrXdXsDT+iit7s0CkWteKjN4rmdKAwLV0C7kklLnqQ22Hh8uuQwD9YXbjPaSt5L9HD9kP5hLfjByw== X-Received: by 2002:a05:600c:1c8b:b0:3d9:f492:f25f with SMTP id k11-20020a05600c1c8b00b003d9f492f25fmr27372163wms.16.1674568237200; Tue, 24 Jan 2023 05:50:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:50:36 -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/3] thermal/drivers/imx: Use the thermal framework for the trip point Date: Tue, 24 Jan 2023 14:50:22 +0100 Message-Id: <20230124135024.366486-2-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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 0d94d4baea33..c115a696e83f 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -332,26 +332,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 = tz->devdata; + 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); -- 2.34.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 4DB94C25B4E for ; Tue, 24 Jan 2023 14:05:17 +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=S9gRtTPkNCQB3l/7K+/0to0GvnENuIrGCU33bgMw5Ds=; b=M7EzDh/p2ukd6x CrENcnDb/5rd7nhnbRxvyEnK7HcVgPJlyC4QG4bWyfuqMKh+xVLfIghvRqySVrjoGjtKaPR2lxLx1 184Kd2S0jbLSWnYmnBatz4dQvfBfDTIaMq924pV966FLOQbC1iH3ej+Hvo4ERk5+BqLxrod3WrHhV 7LXsD7jenkvsrKaaFloWBwDj1Co8I7GTMHBNf51pekxpWZazE41t/Ag2wVpW0lzjcZ1L/GQLLv3hB q5xfN/QGAUd/iOj2oXEXJoph+mKXJCNbAyNWsDJg5ieXNY4gigOWD2Io4VXlDUT7dXuurWfYsx+3T AK2rhpYyDDPicsmis33w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKJu5-004B4D-Vu; Tue, 24 Jan 2023 14:04:02 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKJhB-0045AE-6m for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 13:50:43 +0000 Received: by mail-wm1-x335.google.com with SMTP id fl11-20020a05600c0b8b00b003daf72fc844so12892940wmb.0 for ; Tue, 24 Jan 2023 05:50:38 -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=7KeFsLzGCqHOmLoq3WaiVqhzSWU0bcZhMSI7GPr+4hM=; b=kiPlOFixsP6261tglxcomRwMECun5vCh3UCI9DA5wkN0ooI8SqUUURqeyQJs2RtI/t r3JwBy678qo4rOFmyog+Os1f8DbELQYZBlBkbCUikbnaAGwxhVs0DodpIxj6ku3mv2lZ d3f+QR/d/AGRfNkjo8ivadBLxcXHn2kiUrsskJfCbCjLmmAsrDLiWYrOl/OyVf+3bP0Y Av833Q9KawSnvsgdSHJk1Fs5iJg05ciW7jeAqAC/rgQKNQVVPY/MHx6SMoHk3UfWAaTm mmA/aRHv31o8VbAR7phtlYCLQ46YEboe+PcDt3SgaNGJEkttwLWgvKTZ+jDzP7zQOCMC 4avA== 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=7KeFsLzGCqHOmLoq3WaiVqhzSWU0bcZhMSI7GPr+4hM=; b=5UCZOg4i7KMPVA4VYV6Z5BwhrpLjGmdxmQprNfwg9Pw3GIyhmKNCCePJnaXczpeUgB 13WKtO0ev5XA+HKnYsPtClV1/VQsoUW4+hMPy0T/vH3O1y696PI0DsIEvgspD134DsXF 4UFu2XNgyMyXgQC983Va5cckyX25UEZX8nkDqGqR0snjszDsWebDbCmpa0bja6aAkaYI ldPpPPAtORU9uATNPN4oScEmQ+mX8qKHOtY1hk9LtQVmjhmfiqtQxCMsgHogx8V8BzW+ P04p7RsCMBEbK9MImrNuFFUDP121KRwctkznAAJUmwCsf0vzIgvJvmExTIb92rszyMMS 9+Ag== X-Gm-Message-State: AFqh2koZpr+GKirUFg6ggHfp/8ELhq3JM+fpmjSepqOX+DMNQpIgcWab 5XEkJi2mRzuQHuQ0YPRZ5mK85Q== X-Google-Smtp-Source: AMrXdXsDT+iit7s0CkWteKjN4rmdKAwLV0C7kklLnqQ22Hh8uuQwD9YXbjPaSt5L9HD9kP5hLfjByw== X-Received: by 2002:a05:600c:1c8b:b0:3d9:f492:f25f with SMTP id k11-20020a05600c1c8b00b003d9f492f25fmr27372163wms.16.1674568237200; Tue, 24 Jan 2023 05:50:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:50:36 -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/3] thermal/drivers/imx: Use the thermal framework for the trip point Date: Tue, 24 Jan 2023 14:50:22 +0100 Message-Id: <20230124135024.366486-2-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_055041_360766_BC1E1681 X-CRM114-Status: GOOD ( 21.42 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 0d94d4baea33..c115a696e83f 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -332,26 +332,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 = tz->devdata; + 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); -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel