Add thermal path for AP and Battery
authorlokilee73 <changjoo.lee@samsung.com>
Fri, 4 Jan 2019 12:53:56 +0000 (21:53 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Mon, 14 Jan 2019 10:26:10 +0000 (19:26 +0900)
Change-Id: I464c67d2d8472ae67feb4f4638e35b5b9c5040bf
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/thermal/thermal.c

index 0993081..08579fb 100644 (file)
@@ -26,7 +26,8 @@
 #include <hw/thermal.h>
 #include <hw/shared.h>
 
-#define THERMAL_PATH "/sys/class/sec/temperature/ap_therm"
+#define AP_PATH "/sys/class/sec/temperature/ap_therm"
+#define BATTERY_PATH "/sys/class/sec/temperature/batt_therm"
 
 static struct event_data {
        ThermalUpdated updated_cb;
@@ -35,7 +36,7 @@ static struct event_data {
 
 static guint timer;
 
-static int thermal_get_info(struct thermal_info *info)
+static int thermal_get_info(device_thermal_e type, struct thermal_info *info)
 {
        FILE *fp;
        char buf[32];
@@ -45,16 +46,20 @@ static int thermal_get_info(struct thermal_info *info)
        if (!info)
                return -EINVAL;
 
-       fp = fopen(THERMAL_PATH, "r");
+       if (type == DEVICE_THERMAL_BATTERY)
+               fp = fopen(BATTERY_PATH, "r");
+       else
+               fp = fopen(AP_PATH, "r");
+
        if (!fp) {
-               _E("Failed to open %s(%d)", THERMAL_PATH, errno);
+               _E("Failed to open thermal path(%d)", errno);
                return -errno;
        }
 
        len = fread(buf, 1, sizeof(buf) - 1, fp);
        fclose(fp);
        if (len == 0) {
-               _E("Failed to read %s(%d)", THERMAL_PATH, errno);
+               _E("Failed to read thermal value(%d)", errno);
                return -errno;
        }
        buf[len] = '\0';
@@ -73,7 +78,7 @@ static int thermal_get_info(struct thermal_info *info)
        }
        info->adc = atoi(ret + 4); /* 4 == strlen("adc:") */
 
-       _I("AP temp(%d) adc(%d)", info->temp, info->adc);
+       _I("temp(%d) adc(%d)", info->temp, info->adc);
 
        return 0;
 }
@@ -83,9 +88,9 @@ static gboolean thermal_timeout(gpointer data)
        struct thermal_info info;
        int ret;
 
-       ret = thermal_get_info(&info);
+       ret = thermal_get_info(DEVICE_THERMAL_AP, &info);
        if (ret < 0) {
-               _E("Failed to read thermal state (%d)", ret);
+               _E("Failed to read thermal info (%d)", ret);
                return G_SOURCE_CONTINUE;
        }