diff options
author | Leo Yan <leo.yan@linaro.org> | 2016-03-29 19:23:32 +0800 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2016-04-27 15:54:01 -0700 |
commit | 5fdfc48bb0da2aa8a912024a6ecca06486eb9141 (patch) | |
tree | dfde889af6cfa191cdd388aa7eb7ddc07ed4dc70 | |
parent | 913f201083c81cf021f050d041352ac854c4b526 (diff) | |
download | talos-obmc-linux-5fdfc48bb0da2aa8a912024a6ecca06486eb9141.tar.gz talos-obmc-linux-5fdfc48bb0da2aa8a912024a6ecca06486eb9141.zip |
thermal: hisilicon: increase temperature resolution
When calculate temperature, old code firstly do division and then
convert to "millicelsius" unit. This will lose resolution and only can
read back temperature with "Celsius" unit.
So firstly scale step value to "millicelsius" and then do division, so
finally we can increase resolution for temperature value. Also refine
the calculation from temperature value to step value.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r-- | drivers/thermal/hisi_thermal.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 36d07295f8e3..5e820b541506 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -68,12 +68,12 @@ static inline int _step_to_temp(int step) * Every step equals (1 * 200) / 255 celsius, and finally * need convert to millicelsius. */ - return (HISI_TEMP_BASE + (step * 200 / 255)) * 1000; + return (HISI_TEMP_BASE * 1000 + (step * 200000 / 255)); } static inline long _temp_to_step(long temp) { - return ((temp / 1000 - HISI_TEMP_BASE) * 255 / 200); + return ((temp - HISI_TEMP_BASE * 1000) * 255) / 200000; } static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data, |