Skip to content

Commit

Permalink
thermal: hisilicon: increase temperature resolution
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Leo Yan authored and Eduardo Valentin committed Apr 27, 2016
1 parent 913f201 commit 5fdfc48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/thermal/hisi_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5fdfc48

Please sign in to comment.