]> Git Repo - linux.git/commitdiff
thermal: hisilicon: increase temperature resolution
authorLeo Yan <[email protected]>
Tue, 29 Mar 2016 11:23:32 +0000 (19:23 +0800)
committerEduardo Valentin <[email protected]>
Wed, 27 Apr 2016 22:54:01 +0000 (15:54 -0700)
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 <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
drivers/thermal/hisi_thermal.c

index 36d07295f8e3ac6724181f9dc99152c78db1eb08..5e820b5415063b17fdd2982c0adfd5885db769b9 100644 (file)
@@ -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,
This page took 0.056537 seconds and 4 git commands to generate.