提交 a87dd797 编写于 作者: C Caesar Wang 提交者: Eduardo Valentin

thermal: rockchip: fixes the code_to_temp for tsadc driver

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 020ba95d ("thermal: rockchip:
Add the sort mode for adc value increment or decrement").
Reported-by: NRocky Hao <rocky.hao@rock-chips.com>
Signed-off-by: NCaesar Wang <wxt@rock-chips.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
上级 ab5b52f1
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册