thermal: rockchip: fix up the code to temp maybe overflow

For linear calculation, code needs to be converted to Int,
otherwise the calculated value may overflow at ultra-low temperature.

Change-Id: I64c45b1f5ebc86da853180ca7bb3cb83234f2a64
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
This commit is contained in:
Elaine Zhang
2020-09-07 09:09:57 +08:00
committed by Tao Huang
parent 6e875bbb8e
commit da78c4a700

View File

@@ -623,7 +623,7 @@ static int rk_tsadcv2_code_to_temp(const struct chip_tsadc_table *table,
unsigned long denom;
if (table->kNum) {
*temp = ((code - table->bNum) * 10000 / table->kNum) * 100;
*temp = (((int)code - table->bNum) * 10000 / table->kNum) * 100;
if (*temp < MIN_TEMP || *temp > MAX_TEMP)
return -EAGAIN;
return 0;