Change thermal_get_state to thermal_get_info
authorlokilee73 <changjoo.lee@samsung.com>
Tue, 11 Dec 2018 06:35:06 +0000 (15:35 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Tue, 11 Dec 2018 06:38:15 +0000 (15:38 +0900)
Device state has to be decided from Deviced.
So, change thermal_get_info to support temp and adc.

Change-Id: I48c88a27e725822f83a726b6342acb454ff81719
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/thermal/thermal.c

index 3027fb0..0993081 100755 (executable)
@@ -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 < 46) {
-               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 < 48)
-               info->level = THERMAL_LEVEL_WARNING;
-       else if (value < 53)
-               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;