From: lokilee73 Date: Wed, 26 Dec 2018 11:16:31 +0000 (+0900) Subject: Change thermal_get_state to thermal_get_info X-Git-Tag: submit/tizen/20210604.124315~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41cb4f77c28a10dededebdfeb6a7fc32b256b6d9;p=platform%2Fhal%2Fbackend%2Ftm1%2Fdevice-tm1.git Change thermal_get_state to thermal_get_info Change-Id: I06f91170f755365294a49c52f7e3758a33437613 Signed-off-by: lokilee73 --- diff --git a/hw/thermal/thermal.c b/hw/thermal/thermal.c old mode 100644 new mode 100755 index c423668..0993081 --- 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 < 75) { - 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 < 85) - info->level = THERMAL_LEVEL_WARNING; - else if (value < 100) - 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;