From: Dongwoo Lee Date: Mon, 9 Aug 2021 03:26:26 +0000 (+0900) Subject: pass: thermal: Notify scenario only when it changed X-Git-Tag: accepted/tizen/unified/20210827.110834~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F13%2F262413%2F4;p=platform%2Fcore%2Fsystem%2Fpass.git pass: thermal: Notify scenario only when it changed Since this, thermal monitor notify scenario when it is different with previous on. To this end, set callback to thermal_result for notifying scenario, and it called when the scenario is changed. And this also enables to do different notification process for both thermal_monitor and get_scenario handler. Change-Id: Ib0e7cda2926f4402563b00e94125511954b2a043 Signed-off-by: Dongwoo Lee --- diff --git a/src/pass/pass-thermal.c b/src/pass/pass-thermal.c index 9f21123..07a1b95 100644 --- a/src/pass/pass-thermal.c +++ b/src/pass/pass-thermal.c @@ -36,7 +36,8 @@ #define DEFAULT_TEMPERATURE (-1000) static int thermal_update(struct pass_resource *res, - struct resmon_result_src_thermal *thermal_result) + struct resmon_result_src_thermal *thermal_result, + void (*post_fn)(void *, void *), void *post_data) { struct pass_thermal *thermal = &res->thermal;; struct pass_scenario *new_scenario; @@ -128,6 +129,13 @@ static int thermal_update(struct pass_resource *res, res->config_data.res_name, RESMON_SRC_THERMAL); } + /* + * After update thermal, if post process such as notification is + * required, do those jobs here. + */ + if (post_fn) + post_fn(res, post_data); + _I("Monitor '%-12s' of '%s' resource ('%3d' degrees,'%5d' ms)\n", new_scenario->name, res->config_data.res_name, @@ -136,6 +144,26 @@ static int thermal_update(struct pass_resource *res, return 0; } +static void notify_thermal_data(void *data, void *user_data) +{ + struct pass_resource *res = data; + struct pass_thermal *thermal = &res->thermal; + struct device_notifier_thermal_data thermal_data; + + thermal_data.name = res->config_data.res_thermal_name; + thermal_data.scenario = + thermal->scenarios[thermal->curr_scenario_idx].name; + thermal_data.priority = res->config_data.res_thermal_priority; + + /* + * Send notification with thermal scenario name according to + * measured temperature of each h/w resource. + */ + device_notify(DEVICE_NOTIFIER_THERMAL, (void *)&thermal_data); + + return 0; +} + /** * @brief Decide the proper thermal scenario by using both the monitored * raw data of thermal information and the parsed thermal @@ -150,9 +178,7 @@ static int thermal_update(struct pass_resource *res, static int thermal_monitor_func(void *result, void *user_data) { struct pass_resource *res = user_data; - struct pass_thermal *thermal = &res->thermal;; struct resmon_result_src_thermal *thermal_result; - struct device_notifier_thermal_data thermal_data; int ret; /* Get thermal_result raw data by monitoring */ @@ -163,29 +189,31 @@ static int thermal_monitor_func(void *result, void *user_data) * of thermal information and the parsed thermal information * from scenario section. */ - ret = thermal_update(res, thermal_result); + ret = thermal_update(res, thermal_result, notify_thermal_data, NULL); if (ret < 0) return ret; - thermal_data.name = res->config_data.res_thermal_name; - thermal_data.scenario = - thermal->scenarios[thermal->curr_scenario_idx].name; - thermal_data.priority = res->config_data.res_thermal_priority; + return 0; +} + +static void response_scenario(void *data, void *user_data) +{ + struct pass_resource *res = data; + struct pass_thermal *thermal = &res->thermal; + void **scenario = user_data; /* - * Send notification with thermal scenario name according to - * measured temperature of each h/w resource. + * Inform the thermal scenario name to + * DEVICE_NOTIFIER_THERMAL_GET_SCENARIO client. */ - device_notify(DEVICE_NOTIFIER_THERMAL, (void *)&thermal_data); + *scenario = (void *)thermal->scenarios[thermal->curr_scenario_idx].name; return 0; } static int thermal_get_scenario(void *data, void *user_data) { - void **scenario = data; struct pass_resource *res = user_data; - struct pass_thermal *thermal = &res->thermal;; struct resmon_result_src_thermal *thermal_result; int ret; @@ -197,16 +225,10 @@ static int thermal_get_scenario(void *data, void *user_data) * of thermal information and the parsed thermal information * from scenario section. */ - ret = thermal_update(res, thermal_result); + ret = thermal_update(res, thermal_result, response_scenario, data); if (ret < 0) return ret; - /* - * Inform the thermal scenario name to - * DEVICE_NOTIFIER_THERMAL_GET_SCENARIO client. - */ - *scenario = (void *)thermal->scenarios[thermal->curr_scenario_idx].name; - return 0; }