pass-hal: standard: Fix bug of get_temp when reading the temperature 02/225702/3
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 7 Feb 2020 08:08:42 +0000 (17:08 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 26 Feb 2020 04:31:43 +0000 (13:31 +0900)
Thermal framework of linux kernel provides the current temperature
as five digits interger like 54430 when temperature is 54.430
degrees centigrade. But, Thermal Monitor in Tizen usually uses
double digits interger without decimal point. So that round temperature value.

Change-Id: I3eebe5bf7293c1a7edec7cadc27c81d18ac35ad6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/cpu/cpu.c
src/gpu/gpu.c

index d6606aaf0b5160261c52835bbbaf6b21036277c5..6208cef2ccede3984f28c3389d2b985eb7c6c6f8 100644 (file)
@@ -48,6 +48,7 @@
 #define TMU_PATH_PREFIX                                "/sys/class/thermal/"
 #define TMU_TEMP_PATH_SUFFIX                   "/temp"
 #define TMU_POLICY_PATH_SUFFIX                 "/policy"
+#define TMU_MAX_TEMP_MASK                              0xFFFFF
 
 static int standard_dvfs_get_curr_governor(char *res_name, char *governor)
 {
@@ -362,7 +363,17 @@ static int standard_tmu_get_temp(char *res_thermal_name)
        if (ret < 0)
                return ret;
 
-       return temp;
+       /*
+        * Thermal framework provides the current temperature
+        * as five digits interger like 54430 when temperature is 54.430
+        * degrees centigrade. But, Thermal Monitor in Tizen usually
+        * use two digits interger without decimal point.
+        * So that round temperature value. It constraints the maximume
+        * temperature as 1048 degrees centigrade for preventing integer
+        * overflow. Usually, the embedded device never over 1000 degrees
+        * centigrade.
+        */
+       return (((temp & TMU_MAX_TEMP_MASK) + 500) / 1000);
 }
 
 static int standard_tmu_get_policy(char *res_thermal_name, char *policy)
index 4009fd0dcea3e29f9d76622945ed1a4e4d531eac..1b98c42286788243a38020301d86f7f9f8a92036 100644 (file)
@@ -34,6 +34,7 @@
 #define TMU_PATH_PREFIX                                "/sys/class/thermal/"
 #define TMU_TEMP_PATH_SUFFIX                   "/temp"
 #define TMU_POLICY_PATH_SUFFIX                 "/policy"
+#define TMU_MAX_TEMP_MASK                              0xFFFFF
 
 static int standard_dvfs_get_curr_governor(char *res_name, char *governor)
 {
@@ -203,7 +204,17 @@ static int standard_tmu_get_temp(char *res_thermal_name)
        if (ret < 0)
                return ret;
 
-       return temp;
+       /*
+        * Thermal framework provides the current temperature
+        * as five digits interger like 54430 when temperature is 54.430
+        * degrees centigrade. But, Thermal Monitor in Tizen usually
+        * use two digits interger without decimal point.
+        * So that round temperature value. It constraints the maximume
+        * temperature as 1048 degrees centigrade for preventing integer
+        * overflow. Usually, the embedded device never over 1000 degrees
+        * centigrade.
+        */
+       return (((temp & TMU_MAX_TEMP_MASK) + 500) / 1000);
 }
 
 static int standard_tmu_get_policy(char *res_thermal_name, char *policy)