pass-hal: tm2: Update TMU HAL functions to use pass_res_thermal_name
[platform/adaptation/tm2/pass-hal-tm2.git] / src / gpu / gpu.c
index 7954031..46b0dec 100644 (file)
@@ -1,3 +1,20 @@
+/*
+ * PASS (Power Aware System Service)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 #include <errno.h>
 #include <limits.h>
 #include <pass/hal.h>
 #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];
@@ -178,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;
@@ -187,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);
@@ -199,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;
@@ -207,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);