diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2018-12-11 15:35:06 +0900 |
---|---|---|
committer | lokilee73 <changjoo.lee@samsung.com> | 2018-12-11 15:38:15 +0900 |
commit | 24a8d92036754bf41fd2db2b7a77d48f62e594e3 (patch) | |
tree | 903f46cebbe5ac43a5692159dc0d6eb901280cc1 | |
parent | a2c6e512d6abe676c201048c472df370e940aaa3 (diff) | |
download | device-tw3-24a8d92036754bf41fd2db2b7a77d48f62e594e3.tar.gz device-tw3-24a8d92036754bf41fd2db2b7a77d48f62e594e3.tar.bz2 device-tw3-24a8d92036754bf41fd2db2b7a77d48f62e594e3.zip |
Change thermal_get_state to thermal_get_info
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>
-rwxr-xr-x | hw/thermal/thermal.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/hw/thermal/thermal.c b/hw/thermal/thermal.c index 3027fb0..0993081 100755 --- a/hw/thermal/thermal.c +++ b/hw/thermal/thermal.c @@ -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; |