Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbdINXTy (ORCPT ); Thu, 14 Sep 2017 19:19:54 -0400 Received: from smtp-out-no.shaw.ca ([64.59.134.12]:59563 "EHLO smtp-out-no.shaw.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392AbdINXTx (ORCPT ); Thu, 14 Sep 2017 19:19:53 -0400 X-Authority-Analysis: v=2.2 cv=a+JAzQaF c=1 sm=1 tr=0 a=k5HOQ6ZN7M0zyjl8M7O1NA==:117 a=k5HOQ6ZN7M0zyjl8M7O1NA==:17 a=2JCJgTwv5E4A:10 a=Q-fNiiVtAAAA:8 a=3_Vd9IN7euBQcS1p9cwA:9 a=Fp8MccfUoT0GBdDC_Lng:22 From: Markus Mayer To: Zhang Rui , Eduardo Valentin , Doug Berger , Brian Norris , Florian Fainelli , Dan Carpenter , Colin King Cc: Markus Mayer , Power Management List , ARM Kernel List , Linux Kernel Mailing List Subject: [PATCH] thermal: brcmstb: disable trip points properly when needed Date: Thu, 14 Sep 2017 16:19:27 -0700 Message-Id: <20170914231928.45542-1-code@mmayer.net> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: X-CMAE-Envelope: MS4wfAIQz9y7BlZZBXMYb6N5bA3XN+FxWALNW7vNA0chhzmvDtPjJpe67qYVQfOq/HOVWWBDcEsh2Pf+oWVbeG5tjVT6Du0UX77DlACr4+a5vH9NLYV6uG47 4bEZY3wS918yfN/YaD3SYzmSp8d10nC1pn5oZxR05G3WHWWwYbZlq6ZFyIITZqzZKFMCBtvZVLnTyz8BRGe+FiBiIWeB36btGZoyzmMqBeUph3KeJ57dDFxP qLmaRbzvQeHNmou4U0KYbmEwRAXZMsuaBqIRJyjO3ySgVdzwTulxpdS8xN7FWr6k7Aej4G1CCmLbRsjz7Qr3iB1yuSIPQGpDGHfLfgEpkWoLwBvicVe1ACfI iB/A3xIFDAniuqfV5aXlQDAvEKwDRnlKeukArdjWGLmz1PeWm/GzblDAs1Qjl3rQ25tPGQVCJizB83kMR7a7ULQo5RYzz6LmyKtW7SoHS8qWUhA06abxpXUy vib3wXB3XwPCNZu+9gKUtI2ym0OeYLFAEem7MJz+F8KAuprSEq3ZVFPBAP069RbFuzp3ZrAjQ4LGdGwR Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1958 Lines: 59 From: Markus Mayer The code checking for low and high temperature points was still based on an earlier implementation of the driver. It wasn't working properly with the data types currently being used. We fix this by disabling the high trip point if our high temperature is INT_MAX and disabling the low trip point if our low temperature is -INT_MAX (or lower). Signed-off-by: Markus Mayer --- Here is my patch for the issue described. Please let me know if I should be squashing this into the driver patch and re-submit the entire series. drivers/thermal/broadcom/brcmstb_thermal.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index 87b8e7a..1919f91 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -277,22 +277,23 @@ static int brcmstb_set_trips(void *data, int low, int high) dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high); - if (low) { - if (low > INT_MAX) - low = INT_MAX; + /* + * Disable low-temp if "low" is too small. As per thermal framework + * API, we use -INT_MAX rather than INT_MIN. + */ + if (low <= -INT_MAX) { + avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_LOW, 0); + } else { avs_tmon_set_trip_temp(priv, TMON_TRIP_TYPE_LOW, low); avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_LOW, 1); - } else { - avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_LOW, 0); } - if (high < ULONG_MAX) { - if (high > INT_MAX) - high = INT_MAX; + /* Disable high-temp if "high" is too big. */ + if (high == INT_MAX) { + avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_HIGH, 0); + } else { avs_tmon_set_trip_temp(priv, TMON_TRIP_TYPE_HIGH, high); avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_HIGH, 1); - } else { - avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_HIGH, 0); } return 0; -- 2.7.4