Skip to content

Commit 5fdfc48

Browse files
Leo YanEduardo Valentin
authored andcommitted
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>
1 parent 913f201 commit 5fdfc48

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/thermal/hisi_thermal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ static inline int _step_to_temp(int step)
6868
* Every step equals (1 * 200) / 255 celsius, and finally
6969
* need convert to millicelsius.
7070
*/
71-
return (HISI_TEMP_BASE + (step * 200 / 255)) * 1000;
71+
return (HISI_TEMP_BASE * 1000 + (step * 200000 / 255));
7272
}
7373

7474
static inline long _temp_to_step(long temp)
7575
{
76-
return ((temp / 1000 - HISI_TEMP_BASE) * 255 / 200);
76+
return ((temp - HISI_TEMP_BASE * 1000) * 255) / 200000;
7777
}
7878

7979
static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data,

0 commit comments

Comments
 (0)