pass-hal: tm2: Update TMU HAL functions to use pass_res_thermal_name 47/137647/3
authorWook Song <wook16.song@samsung.com>
Fri, 7 Jul 2017 02:46:18 +0000 (11:46 +0900)
committerWook Song <wook16.song@samsung.com>
Fri, 7 Jul 2017 05:42:45 +0000 (14:42 +0900)
This patch updates all HAL function bodies for TMU to use the new
pass_res_thermal_name property of the 'pass.conf' file.

Change-Id: I7f9b4507576d0d5e79ce7b503710193501617eab
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
src/cpu/cpu.c
src/gpu/gpu.c

index 1683cfe..f05c510 100644 (file)
 #define CPU_ONLINE_STATE_ON                    1
 #define CPU_ONLINE_STATE_OFF                   0
 
-#define TMU_PATH_PREFIX                                "/sys/class/thermal/thermal_zone"
+#define TMU_PATH_PREFIX                                "/sys/class/thermal/"
 #define TMU_TEMP_PATH_SUFFIX                   "/temp"
 #define TMU_POLICY_PATH_SUFFIX                 "/policy"
 
 #define TM2_CPU_MIN_NUM                                0
 #define TM2_CPU_MAX_NUM                                7
 
-#define TM2_CPU_LITTLE_RESNAME                 "cpu0"
-#define TM2_CPU_BIG_RESNAME                    "cpu4"
-#define TM2_CPU_LITTLE_THERMAL_ZONE_NUM                3
-#define TM2_CPU_BIG_THERMAL_ZONE_NUM           0
-
-
 static int tm2_dvfs_get_curr_governor(char *res_name, char *governor)
 {
        char path[PATH_MAX];
@@ -327,25 +321,17 @@ static struct pass_resource_hotplug_ops tm2_cpu_hotplus_ops = {
        .set_online_max_num = NULL,
 };
 
-static int tm2_tmu_get_temp(char *res_name)
+static int tm2_tmu_get_temp(char *res_thermal_name)
 {
        char path[PATH_MAX];
-       int tz_num, temp;
-       int ret;
+       int temp, ret;
 
-       if (!res_name)
+       if (!res_thermal_name)
                return -EINVAL;
 
-       if (!strcmp(res_name, TM2_CPU_LITTLE_RESNAME))
-               tz_num = TM2_CPU_LITTLE_THERMAL_ZONE_NUM;
-       else if (!strcmp(res_name, TM2_CPU_BIG_RESNAME))
-               tz_num = TM2_CPU_BIG_THERMAL_ZONE_NUM;
-       else
-               return -EINVAL;
-
-       snprintf(path, PATH_MAX, "%s%d%s",
+       snprintf(path, PATH_MAX, "%s%s%s",
                TMU_PATH_PREFIX,
-               tz_num,
+               res_thermal_name,
                TMU_TEMP_PATH_SUFFIX);
 
        ret = sysfs_read_int(path, &temp);
@@ -355,24 +341,17 @@ static int tm2_tmu_get_temp(char *res_name)
        return temp;
 }
 
-static int tm2_tmu_get_policy(char *res_name, char *policy)
+static int tm2_tmu_get_policy(char *res_thermal_name, char *policy)
 {
        char path[PATH_MAX];
-       int ret, tz_num;
-
-       if ((!res_name) || (!policy))
-               return -EINVAL;
+       int ret;
 
-       if (!strcmp(res_name, TM2_CPU_LITTLE_RESNAME))
-               tz_num = TM2_CPU_LITTLE_THERMAL_ZONE_NUM;
-       else if (!strcmp(res_name, TM2_CPU_BIG_RESNAME))
-               tz_num = TM2_CPU_BIG_THERMAL_ZONE_NUM;
-       else
+       if ((!res_thermal_name) || (!policy))
                return -EINVAL;
 
-       snprintf(path, PATH_MAX, "%s%d%s",
+       snprintf(path, PATH_MAX, "%s%s%s",
                TMU_PATH_PREFIX,
-               tz_num,
+               res_thermal_name,
                TMU_POLICY_PATH_SUFFIX);
 
        ret = sysfs_read_str(path, policy, BUFF_MAX);
index aaf9cc4..46b0dec 100644 (file)
 #define DEVFREQ_GPU_MIN_FREQ_PATH_SUFFIX       "/min_freq"
 #define DEVFREQ_GPU_MAX_FREQ_PATH_SUFFIX       "/max_freq"
 
-#define TMU_PATH_PREFIX                                "/sys/class/thermal/thermal_zone"
+#define TMU_PATH_PREFIX                                "/sys/class/thermal/"
 #define TMU_TEMP_PATH_SUFFIX                   "/temp"
 #define TMU_POLICY_PATH_SUFFIX                 "/policy"
 
-#define TM2_GPU_THERMAL_ZONE_NUM               2
-
 static int tm2_dvfs_get_curr_governor(char *res_name, char *governor)
 {
        char path[PATH_MAX];
@@ -195,7 +193,7 @@ static struct pass_resource_dvfs_ops tm2_gpu_dvfs_ops =  {
        .get_load_table = NULL,
 };
 
-static int tm2_tmu_get_temp(char *res_name)
+static int tm2_tmu_get_temp(char *res_thermal_name);
 {
        char path[PATH_MAX];
        int temp;
@@ -204,9 +202,9 @@ static int tm2_tmu_get_temp(char *res_name)
        if (!res_name)
                return -EINVAL;
 
-       snprintf(path, PATH_MAX, "%s%d%s",
+       snprintf(path, PATH_MAX, "%s%s%s",
                TMU_PATH_PREFIX,
-               TM2_GPU_THERMAL_ZONE_NUM,
+               res_thermal_name,
                TMU_TEMP_PATH_SUFFIX);
 
        ret = sysfs_read_int(path, &temp);
@@ -216,7 +214,7 @@ static int tm2_tmu_get_temp(char *res_name)
        return temp;
 }
 
-static int tm2_tmu_get_policy(char *res_name, char *policy)
+static int tm2_tmu_get_policy(char *res_thermal_name, char *policy)
 {
        char path[PATH_MAX];
        int ret;
@@ -224,9 +222,9 @@ static int tm2_tmu_get_policy(char *res_name, char *policy)
        if ((!res_name) || (!policy))
                return -EINVAL;
 
-       snprintf(path, PATH_MAX, "%s%d%s",
+       snprintf(path, PATH_MAX, "%s%s%s",
                TMU_PATH_PREFIX,
-               TM2_GPU_THERMAL_ZONE_NUM,
+               res_thermal_name,
                TMU_POLICY_PATH_SUFFIX);
 
        ret = sysfs_read_str(path, policy, BUFF_MAX);