From patchwork Tue Jan 24 13:50: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: 47712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2168988wrn; Tue, 24 Jan 2023 06:11:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXu1tkjS5uZSi2JnFNo8FVkV9RbxL2gdvpAER/7saHNet65EIx7AZ/TlMgDGy/kjr9x1yedR X-Received: by 2002:aa7:9e9e:0:b0:580:9431:1b1a with SMTP id p30-20020aa79e9e000000b0058094311b1amr31374356pfq.5.1674569480038; Tue, 24 Jan 2023 06:11:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674569480; cv=none; d=google.com; s=arc-20160816; b=ADp2mgVnrVtsHudqtGCcZ59+Xa484oSo/sqdHIGrlKUwAiY+8pZynP4a2dhe/QwD0+ gVCpgNtrR4kInbxPv/YyCGQa4KdrvP3x41O0DAoYQqb2+YKm3ihyZzB8zhwwAq9tBr+S eG1zXS4HKZuMGFhvVDaMnOAcFAuKhuyAtQ/JzUxIc+QUOzKgodLfYVmuxlHKFViXKA0F T/kPGhDEvFFNmpx+DKxJln1yH/jg31UpFwl7woaMHDFCnGl81vNxh83MICJHXHAe3Wgt cyZLdOgsomNrmIK7RjCn0pfaXc7XRiZ4RYrJss33lkvo3aG+Lg//z8zG3+ecNkcIc60F oC9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=KdNKBm9dCMT5uwH0jJSmOk/S2BVD6poXI4UEU8hMcS4=; b=ZQKScnurUcm3FjnkOMR6KApMuBN6UHN4r3e0A7OjUi1wIU5j2YMa9CkL8RrX0pIdwW MMwUrxFArf0GYKs1SlIPdstogQ66Zz+w5G9u6VnilFUrre7HoRmeTG2bceNtl6ttXCpN YJbaiS5RbkmtBSxMPwMlhwe24eGplcsgc88X0tsy4MAzEX9VkwcmKYu/I8xyeA/vaT7L XoYJagPZlT2IYEW5DoaJvrd1IF6oAL3S65sDpjPjvkQZx6I0OujhN761RZB1FwPfGutq thaql0M9USf1Gti811EhKL06mlYDc59rBW6BMaS1t+a4qXbp4ZfsmmKRcDpdhHnAKsRR e2cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lx/21U8j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck13-20020a056a00328d00b0058bc6870d1bsi2529305pfb.94.2023.01.24.06.11.07; Tue, 24 Jan 2023 06:11:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lx/21U8j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbjAXNxv (ORCPT + 99 others); Tue, 24 Jan 2023 08:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbjAXNx2 (ORCPT ); Tue, 24 Jan 2023 08:53:28 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC99649549 for ; Tue, 24 Jan 2023 05:51:22 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id m15so11481935wms.4 for ; Tue, 24 Jan 2023 05:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KdNKBm9dCMT5uwH0jJSmOk/S2BVD6poXI4UEU8hMcS4=; b=lx/21U8jUJGqSVM9i0svqPlaaG3+0DuV1wZ6usLlLKooLymgkn2yujl6xNPqW7Zvh9 9hfPkIDo7UW9c/xCwVawPbhZTYmVHn297MrmAjg3e7bTVZ/MUPZ19JsmjUOH+uwW4mzI hY8Z3E6rV1ybpHQTapr7tWZUA0mgoYr9XmGQ0JLN0DwMfpXyUcjD0fhSNT4/nmbY2Xtz uM7Xf9/FUp7LVaikISToWjm5fFb284ZeSj6pxXs0I4/ZraPjaxf2+xuyEGGeMgrK5bLo LTc2rAIlHhQ6Z8Eo6cg6HKsoGZ7bKEhOEr9OxSpQbFuhj0TFRVsOVYcSgVxb9TV7Jwq6 NFNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KdNKBm9dCMT5uwH0jJSmOk/S2BVD6poXI4UEU8hMcS4=; b=2lOgiYsZmZkEs+dUMyu3WXaiYJkW/KswC67RpOHytwNuRNRBt24mhVWArTb+I0GEVR vSdOp+Cb7ISXXMShuMN7F6h+l4uu7s9iJylBOYxBpd7fPZm6UujiL/4BXhvfyeXq9hGt 5GLuoMnq0vzDsiXvNuLpQ5E2FDXJhYwROiDvN53WeMseg9PZr7ZTpw8rtasM2lwvB/OU GkyLSbhki+FEEHWHGBzbyX/tFRcF4H1MhqYg4bSM3uqtjeKzGAcgeGimLJjV9YqkDY// /WKPZTnNXXNGuso8+CV3aLkOtu4hg9dIdcatXlJhH2q5lHPuyphlPj71pz/qML79FkPU 1yZw== X-Gm-Message-State: AFqh2kp1BeFDIPSDJEvCQZg+S88xUe+UXJyNtVU7KVPpDJUzhARCIQ5m UmNaS/5arZUrvmJnaCrciy3qxGq0F+qYJ//9 X-Received: by 2002:a05:600c:5108:b0:3d3:49db:d84 with SMTP id o8-20020a05600c510800b003d349db0d84mr27336962wms.20.1674568235876; Tue, 24 Jan 2023 05:50:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 05:50:35 -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/3] thermal/drivers/imx: Remove get_trip_temp ops Date: Tue, 24 Jan 2023 14:50:21 +0100 Message-Id: <20230124135024.366486-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755913367251974777?= X-GMAIL-MSGID: =?utf-8?q?1755913367251974777?= 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 fb0d5cab70af..0d94d4baea33 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -332,13 +332,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) { @@ -406,7 +399,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 Tue Jan 24 13:50: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: 47713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2169122wrn; Tue, 24 Jan 2023 06:11:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXtrdnDuGaI9ezKGN3iDW65uzk9hzMl8Nb0mfDfQnMX6mBA6PTqHe3YhJx1/m4111IeLZi0N X-Received: by 2002:a05:6a20:1bd6:b0:b5:f89d:d7b5 with SMTP id cv22-20020a056a201bd600b000b5f89dd7b5mr46996973pzb.14.1674569495686; Tue, 24 Jan 2023 06:11:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674569495; cv=none; d=google.com; s=arc-20160816; b=iT9tBzwevSCJUqROGbdTdfqY/z8LYbzBBCk6zePkJEs+lBF+5vOE1Ys0khDnXo7X3g f42I8NqBa1DZ1k/FyJr7I7RDsFLZ5QIOvgyRiwBgGSdruUK0fmH/T4q7av6EvVXMuBrD BgI1sLhn47MIObD9UYBPhLsfRxW035Ks/nJIaoOdrwHoT86DtqQ8k48firFiouzGrfGr gomf/sAM0yPFXunDgqF90UgNu2pHIfCFDOEl6vTWdn1P1AUQghySAlyjATqb2uW2Kfxx 3MkrM3Ug6YjT7dZNfL52eyUoxL+I+bpEOvDuyR+2qsq4J064PfKDBt7aC/DVKaVyWSxC ReXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7KeFsLzGCqHOmLoq3WaiVqhzSWU0bcZhMSI7GPr+4hM=; b=prgPjM+viCHU6QbM8UJqV4g9adApWlxFZJsYZZNGmgU/qbGhgwbnfaIlr5gfP5Z+p0 3y5eesfgPfbYlEKZd46reNsOpxjn5spWMyhkDra6E3Slq/GhuxZzmvDfe08LjcZHjGpy cceJ7wDHrPBYH2zLZH14WOvEL9zWu1JvqcLqO7vw3GoFQ4kOnKMdpnWqMdi8NUmTuFcP wkZhnQScw9D1P3+2zXbjTBnuYdtXjtsmTnJPHayABMiJ+rJh5uDb+IdLxCbqy+7ytm/5 qovEPuSSgSP/RvvC4Gzz20TpjBrCYQjaeWlaWnp07j1tu6IBpJcNaVkyYGfiUi1yXtpM 5S/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kiPlOFix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a18-20020a637f12000000b004d0ef90d860si2235310pgd.297.2023.01.24.06.11.22; Tue, 24 Jan 2023 06:11:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kiPlOFix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234532AbjAXNxy (ORCPT + 99 others); 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-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-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755913383720182454?= X-GMAIL-MSGID: =?utf-8?q?1755913383720182454?= 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); 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: 47714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2169514wrn; Tue, 24 Jan 2023 06:12:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXsstDoIqjKClGDPEa+qCn4Frkx/yilHiwIV18NJb8a86KiTaYMQ0esB+QSXam7WHgSkMZew X-Received: by 2002:a05:6a20:699b:b0:b8:a4e7:7940 with SMTP id t27-20020a056a20699b00b000b8a4e77940mr36834146pzk.11.1674569535904; Tue, 24 Jan 2023 06:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674569535; cv=none; d=google.com; s=arc-20160816; b=gz4wspdQrx9wS3AyEN/kr76Kmy48MhuYVZcgNTzGU/VTpMXuGJpseIdg2+3qzJazlz ul78UGE4zlxpLxb9wD2dxgByFnF8QG1IeKIiRGegX5IYMd8QOFYzJaTu5uvfOJPGXBTC P7/vdYMwC8v07IP9UPy1xgsY+luKIf5rWJc2PQxVtLj92+eqRhqz1q/eQjq5obcxWEwZ 7ue8okEmqmg31ULbhKC8sdehSC4gxo1prJ5Bqi2lsNaNC2e4b3LsY7C+4jO6agNiiNXk B02NV8DsaBHxstL/CRR4rkY0f9s3CUgJm5kvtRdjU0yjS+ChOAyNbxdUFmHkEKGahEa7 Vz6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GRHFm87xhd5kwGJXeGjCaI1s3MvLoDnYqaOChsF1PF4=; b=GH8rShJze8/IHI3okhbe4pVzsQOwvvRhiAmtDidgsN0BKCOBWajNF/gVZecRrreRj9 69qkRB6BLqg2q7s4MwrOZngVwfTRi2M1yl5/z3ZGujdAXm3PHkl0MbTQDXiXlHkWJS9S 2MEqT3+x3P40lZtQWLqoRTjgzk8TeFXFPuRFxLKZsEVtVBppwL48Po3/GQSMRsgHo1gf dCg//0V6k4sN2IQNuHsqL5+bYCs3K8xcUGKVoVxsSX8di1OcJ9UZJFsZPKuZk+OXBxoZ CYQTPjWm/ZZdkY/aXB71dnljk4mDO93kMkgg1Af89nS3OmufLKLloCHVJZHF4SjErA6v UctA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pcMpDVis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a170902ec8800b00192de3fbb4asi2646411plg.261.2023.01.24.06.11.41; Tue, 24 Jan 2023 06:12:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pcMpDVis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234671AbjAXNxz (ORCPT + 99 others); Tue, 24 Jan 2023 08:53:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234704AbjAXNx3 (ORCPT ); Tue, 24 Jan 2023 08:53:29 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116E64943C for ; Tue, 24 Jan 2023 05:51:24 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id f19-20020a1c6a13000000b003db0ef4dedcso12859499wmc.4 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=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=x/+uH1hNAJ6MNj3LS7lEX5Pk3KiJpWWQiTR7AuZPJBMI3PSqZjXzmag298CByVGLbA lb9sKuqB4qts0isY/QzYok2tSOOA3+n6bNHH8R31qbusANWfAPWmJvKKlmLG51DGb76Y MEo+C+/GUfkc7CbdWlGOpM+SheHVG1ddkN6ST2km2OOzDbuSaUFnUOPs8giMeSuSMHbL Cg6etA6keUGeTTrJItTcwsuh8STwy2DzZq1g3zRADE/hEjck5Guf5wI9svrXQV1kXzUv wh5X5+vfALPd+bs7DgczzRlUVz+Be3/rZiix5UGRBq+GUN05EwIPVOCPt3qy1PCJRyTF N9Hw== X-Gm-Message-State: AFqh2kqzpdj4GX6YjkbAtuZ37CGo5ArFI+PElGG4RJHWi8Xtez8Bc4G/ 4w+HehW4zf4QMJlbK/iFaGOqeA== 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-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755913425735410433?= X-GMAIL-MSGID: =?utf-8?q?1755913425735410433?= 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);