mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user