From: Caesar Wang <wxt@rock-chips.com>
To: edubezval@gmail.com
Cc: Heiko Stuebner <heiko@sntech.de>,
dianders@chromium.org, briannorris@google.com,
smbarber@google.com, linux-rockchip@lists.infradead.org,
Caesar Wang <wxt@rock-chips.com>, Zhang Rui <rui.zhang@intel.com>,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/9] thermal: rockchip: fixes the code_to_temp for tsadc driver
Date: Mon, 18 Apr 2016 11:35:54 +0800 [thread overview]
Message-ID: <1460950562-20652-3-git-send-email-wxt@rock-chips.com> (raw)
In-Reply-To: <1460950562-20652-1-git-send-email-wxt@rock-chips.com>
We should judge the table.id[mid].code insearch algorithm on matter the
adc value increment or decrement.
Or otherwise, the temperature return the incorrect value in some cases.
[ 1.438589] adc_val=402,temp=-40000
[ 1.438903] adc_val=403,temp=-39375
[ 1.439217] adc_val=404,temp=-38750
...
[ 1.441102] adc_val=410,temp=-40000
[ 1.441416] adc_val=411,temp=-34445
[ 1.441737] adc_val=412,temp=-33889
...
Let's fix it right now.
Fixes commit 020ba95dbbbe ("thermal: rockchip:
Add the sort mode for adc value increment or decrement").
Reported-by: Rocky Hao <rocky.hao@rock-chips.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
---
drivers/thermal/rockchip_thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index f4c4bcd..658772f 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -405,8 +405,8 @@ static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
return -EAGAIN; /* Incorrect reading */
while (low <= high) {
- if (code >= table.id[mid - 1].code &&
- code < table.id[mid].code)
+ if (code <= table.id[mid].code &&
+ code > table.id[mid - 1].code)
break;
else if (code > table.id[mid].code)
low = mid + 1;
--
1.9.1
next prev parent reply other threads:[~2016-04-18 3:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 3:35 [PATCH 0/9] thermal: rockchip: Support rk3366/rk3399 SoCS and fixes the driver Caesar Wang
2016-04-18 3:35 ` [PATCH 1/9] thermal: rockchip: disable thermal->clk in err case Caesar Wang
2016-04-18 3:35 ` Caesar Wang [this message]
2016-04-18 3:35 ` [PATCH 3/9] thermal: rockchip: update the tsadc table for rk3399 Caesar Wang
2016-04-18 3:35 ` [PATCH 4/9] thermal: rockchip: handle the power sequence for tsadc controller Caesar Wang
2016-04-27 23:48 ` Eduardo Valentin
[not found] ` <57216C65.5040501@gmail.com>
2016-04-28 15:04 ` Eduardo Valentin
2016-05-03 2:27 ` Caesar Wang
2016-04-18 3:35 ` [PATCH 5/9] thermal: rockchip: Support RK3366 SoCs in the thermal driver Caesar Wang
2016-04-18 3:35 ` [PATCH 6/9] thermal: rockchip: add the notes for better reading Caesar Wang
2016-04-18 3:35 ` [PATCH 7/9] thermal: of: Add support for hardware-tracked trip points Caesar Wang
2016-04-20 23:48 ` Eduardo Valentin
2016-04-21 1:12 ` Brian Norris
2016-04-22 1:54 ` Caesar Wang
2016-04-22 5:41 ` Sascha Hauer
2016-04-22 10:17 ` Caesar Wang
2016-04-27 21:50 ` Eduardo Valentin
2016-04-18 3:36 ` [PATCH 8/9] thermal: rockchip: add the set_trips function Caesar Wang
2016-04-18 3:36 ` [PATCH 9/9] arm64: dts: rockchip: move the rk3368 thermal data into rk3368.dtsi Caesar Wang
2016-04-22 8:18 ` Heiko Stübner
2016-04-27 23:52 ` [PATCH 0/9] thermal: rockchip: Support rk3366/rk3399 SoCS and fixes the driver Eduardo Valentin
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=1460950562-20652-3-git-send-email-wxt@rock-chips.com \
--to=wxt@rock-chips.com \
--cc=briannorris@google.com \
--cc=dianders@chromium.org \
--cc=edubezval@gmail.com \
--cc=heiko@sntech.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=rui.zhang@intel.com \
--cc=smbarber@google.com \
/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
Powered by JetHome