Add thermal path for AP and Battery 39/196439/6 accepted/tizen/unified/20190219.154155 accepted/tizen/unified/20190221.165809 submit/tizen/20190218.105211 submit/tizen/20190220.073046
authorlokilee73 <changjoo.lee@samsung.com>
Fri, 28 Dec 2018 09:15:49 +0000 (18:15 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 18 Feb 2019 10:21:59 +0000 (10:21 +0000)
Change-Id: If0546103bce2ebad837db45985a5f2037cb5d5e3
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/thermal/thermal.c

index 0993081..ccd2c94 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;
        }