static int thermal_get_state(struct thermal_info *info)
{
int ret, value;
+ FILE *fp;
+ char buf[32];
+ size_t len;
if (!info)
return -EINVAL;
- ret = sys_get_int(THERMAL_PATH, &value);
- if (ret < 0) {
- _E("Failed to read %s (%d)", THERMAL_PATH, ret);
- return ret;
+ fp = fopen(THERMAL_PATH, "r");
+ if (!fp) {
+ _E("Failed to open %s(%d)", THERMAL_PATH, 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);
+ return -errno;
+ }
+ buf[len] = '\0';
+
+ if (!strstr(buf, "temp:")) {
+ _E("Invalid temparature value (%s)", buf);
+ return -EINVAL;
}
+ value = atoi(buf + 5); /* 5 == strlen("temp:") */
+
+ _I("AP temparature(%d)", value);
+
if (value < 30) {
info->state = THERMAL_STATE_LOW;
info->level = THERMAL_LEVEL_NORMAL;