thermal/drivers/rcar_gen3: Fix undefined temperature if negative
As description for DIV_ROUND_CLOSEST in file include/linux/kernel.h.
"Result is undefined for negative divisors if the dividend variable
type is unsigned and for negative dividends if the divisor variable
type is unsigned."
In current code, the FIXPT_DIV uses DIV_ROUND_CLOSEST but has not
checked sign of divisor before using. It makes undefined temperature
value in case the value is negative.
This patch fixes to satisfy DIV_ROUND_CLOSEST description
and fix bug too. Note that the variable name "reg" is not good
because it should be the same type as rcar_gen3_thermal_read().
However, it's better to rename the "reg" in a further patch as
Signed-off-by: Van Do <email@example.com>
Signed-off-by: Dien Pham <firstname.lastname@example.org>
[shimoda: minor fixes, add Fixes tag]
Fixes: 564e73d283af ("thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver")
Signed-off-by: Yoshihiro Shimoda <email@example.com>
Reviewed-by: Niklas Soderlund <firstname.lastname@example.org>
Tested-by: Niklas Soderlund <email@example.com>
Reviewed-by: Amit Kucheria <firstname.lastname@example.org>
Signed-off-by: Daniel Lezcano <email@example.com>
1 file changed