summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlokilee73 <changjoo.lee@samsung.com>2019-01-04 21:53:56 +0900
committerlokilee73 <changjoo.lee@samsung.com>2019-01-14 19:26:10 +0900
commit232efa13f019e32e6684611ec9ef0585a4318bf3 (patch)
treeef26c55872dcc9b5aee2b839828dbab1be8ff89f
parentdfbb93dcac81ddfce640af515f7c66a53cbd24b3 (diff)
downloaddevice-tm1-232efa13f019e32e6684611ec9ef0585a4318bf3.tar.gz
device-tm1-232efa13f019e32e6684611ec9ef0585a4318bf3.tar.bz2
device-tm1-232efa13f019e32e6684611ec9ef0585a4318bf3.zip
Add thermal path for AP and Battery
Change-Id: I464c67d2d8472ae67feb4f4638e35b5b9c5040bf Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rw-r--r--hw/thermal/thermal.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/hw/thermal/thermal.c b/hw/thermal/thermal.c
index 0993081..08579fb 100644
--- a/hw/thermal/thermal.c
+++ b/hw/thermal/thermal.c
@@ -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;
}