Change thermal_get_state to thermal_get_info
authorlokilee73 <changjoo.lee@samsung.com>
Wed, 26 Dec 2018 11:16:31 +0000 (20:16 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Wed, 26 Dec 2018 11:17:15 +0000 (20:17 +0900)
Change-Id: I06f91170f755365294a49c52f7e3758a33437613
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/thermal/thermal.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index c423668..0993081
@@ -35,12 +35,12 @@ static struct event_data {
 
 static guint timer;
 
-static int thermal_get_state(struct thermal_info *info)
+static int thermal_get_info(struct thermal_info *info)
 {
-       int value;
        FILE *fp;
        char buf[32];
        size_t len;
+       char *ret;
 
        if (!info)
                return -EINVAL;
@@ -59,29 +59,21 @@ static int thermal_get_state(struct thermal_info *info)
        }
        buf[len] = '\0';
 
-       if (!strstr(buf, "temp:")) {
-               _E("Invalid temparature value (%s)", buf);
+       ret = strstr(buf, "temp:");
+       if (!ret) {
+               _E("Invalid temp value (%s)", buf);
                return -EINVAL;
        }
+       info->temp = atoi(ret + 5); /* 5 == strlen("temp:") */
 
-       value = atoi(buf + 5); /* 5 == strlen("temp:") */
-
-       _I("AP temparature(%d)", value);
-
-       if (value < 75) {
-               info->state = THERMAL_STATE_NORMAL;
-               info->level = THERMAL_LEVEL_NORMAL;
-               return 0;
+       ret = strstr(buf, "adc:");
+       if (!ret) {
+               _E("Invalid adc value (%s)", buf);
+               return -EINVAL;
        }
+       info->adc = atoi(ret + 4); /* 4 == strlen("adc:") */
 
-       info->state = THERMAL_STATE_HIGH;
-
-       if (value < 85)
-               info->level = THERMAL_LEVEL_WARNING;
-       else if (value < 100)
-               info->level = THERMAL_LEVEL_CRITICAL;
-       else
-               info->level = THERMAL_LEVEL_POWEROFF;
+       _I("AP temp(%d) adc(%d)", info->temp, info->adc);
 
        return 0;
 }
@@ -91,7 +83,7 @@ static gboolean thermal_timeout(gpointer data)
        struct thermal_info info;
        int ret;
 
-       ret = thermal_get_state(&info);
+       ret = thermal_get_info(&info);
        if (ret < 0) {
                _E("Failed to read thermal state (%d)", ret);
                return G_SOURCE_CONTINUE;
@@ -150,8 +142,8 @@ static int thermal_open(struct hw_info *info,
                = thermal_register_changed_event;
        thermal_dev->unregister_changed_event
                = thermal_unregister_changed_event;
-       thermal_dev->get_state
-               = thermal_get_state;
+       thermal_dev->get_info
+               = thermal_get_info;
 
        *common = (struct hw_common *)thermal_dev;
        return 0;