linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: wxt@rock-chips.com (Caesar Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/8] thermal: rockchip: fix a impossible condition caused by the warning
Date: Wed,  3 Feb 2016 12:12:42 +0800	[thread overview]
Message-ID: <1454472767-5767-4-git-send-email-wxt@rock-chips.com> (raw)
In-Reply-To: <1454472767-5767-1-git-send-email-wxt@rock-chips.com>

As the Dan report the smatch check the thermal driver warning:
drivers/thermal/rockchip_thermal.c:551 rockchip_configure_from_dt()
warn: impossible condition '(thermal->tshut_temp > ((~0 >> 1))) =>
(s32min-s32max > s32max)'

Although The shut_temp read from DT is u32,the temperature is currently
represented as int not long in the thermal driver.
Let's change to make shut_temp instead of the thermal->tshut_temp for
the condition.

Fixes: commit 437df2172e8d
("thermal: rockchip: consistently use int for temperatures")

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---

 drivers/thermal/rockchip_thermal.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index b58e3fb..433085a 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -693,15 +693,14 @@ static int rockchip_configure_from_dt(struct device *dev,
 			 thermal->chip->tshut_temp);
 		thermal->tshut_temp = thermal->chip->tshut_temp;
 	} else {
+		if (shut_temp > INT_MAX) {
+			dev_err(dev, "Invalid tshut temperature specified: %d\n",
+				shut_temp);
+			return -ERANGE;
+		}
 		thermal->tshut_temp = shut_temp;
 	}
 
-	if (thermal->tshut_temp > INT_MAX) {
-		dev_err(dev, "Invalid tshut temperature specified: %d\n",
-			thermal->tshut_temp);
-		return -ERANGE;
-	}
-
 	if (of_property_read_u32(np, "rockchip,hw-tshut-mode", &tshut_mode)) {
 		dev_warn(dev,
 			 "Missing tshut mode property, using default (%s)\n",
-- 
1.9.1

  parent reply	other threads:[~2016-02-03  4:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03  4:12 [PATCH 0/8] Support and fixes the rk3228 SoCS for thermal Caesar Wang
2016-02-03  4:12 ` [PATCH 2/8] clk: rockchip: add the tsadc clocks found on rk3228 SoCs Caesar Wang
2016-02-03  4:12 ` Caesar Wang [this message]
2016-02-03  4:12 ` [PATCH 4/8] thermal: rockchip: fix calculation error for code_to_temp Caesar Wang
2016-02-03  4:12 ` [PATCH 5/8] thermal: rockchip: the rename compatibles for rockchip SoCs Caesar Wang
2016-02-03  4:12 ` [PATCH 6/8] thermal: rockchip: fix the tsadc sequence output on rk3228/rk3399 Caesar Wang
2016-02-03  4:12 ` [PATCH 7/8] ARM: dts: rockchip: enable the tsadc for rk3228 evb Caesar Wang
2016-02-04  1:34   ` kbuild test robot
2016-02-03  4:12 ` [PATCH 8/8] ARM: dts: rockchip: add the thermal main info found on rk3228 Caesar Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454472767-5767-4-git-send-email-wxt@rock-chips.com \
    --to=wxt@rock-chips.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).