From: Dongwoo Lee Date: Fri, 20 Aug 2021 02:45:41 +0000 (+0900) Subject: pass: thermal: Supprot mupltiple resources for 'thermal_get_scenario' X-Git-Tag: submit/tizen/20210827.070901~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b137c93b487859d1d2549697c254b73a403874e;p=platform%2Fcore%2Fsystem%2Fpass.git pass: thermal: Supprot mupltiple resources for 'thermal_get_scenario' To response 'getCoolDownStatus' dbus method call during boot, initial scenario state should be set before thermal monitor works once. When there are multiple resources which have thermal data, the final state of thermal scenario should be determined theirs priority. For this, this enables supporting multiple resources on 'thermal_get_scenario' handler. Change-Id: I920de0440efac9706405bcf63b0c110b407ddd60 Signed-off-by: Dongwoo Lee --- diff --git a/src/pass/pass-thermal.c b/src/pass/pass-thermal.c index 07a1b95..f882041 100644 --- a/src/pass/pass-thermal.c +++ b/src/pass/pass-thermal.c @@ -198,15 +198,31 @@ static int thermal_monitor_func(void *result, void *user_data) static void response_scenario(void *data, void *user_data) { + static int cur_priority = INT_MAX; struct pass_resource *res = data; struct pass_thermal *thermal = &res->thermal; - void **scenario = user_data; + char **resp = user_data; + int priority = res->config_data.res_thermal_priority; + char *scenario = thermal->scenarios[thermal->curr_scenario_idx].name; /* * Inform the thermal scenario name to * DEVICE_NOTIFIER_THERMAL_GET_SCENARIO client. */ - *scenario = (void *)thermal->scenarios[thermal->curr_scenario_idx].name; + if (priority < cur_priority || !*resp) { + cur_priority = priority; + *resp = scenario; + } else if (priority == cur_priority) { + int i; + + for (i = 0; i < thermal->num_scenarios; i++) { + if (!strncmp(thermal->scenarios[i].name, *resp, strlen(*resp))) { + if (i < thermal->curr_scenario_idx) + *resp = scenario; + break; + } + } + } return 0; } diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index 6b9a04e..a58772c 100644 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -144,13 +144,6 @@ static int thermal_init_done(void *data, void *user_data) g_thermal->list[i].name); } - /* FIXME: - * Currently, initial thermal scenario among multiple resources are not - * settled properly; it is rather determined by one of scenario initialized - * lastly. So, it is required that the method for retrieving the current - * state of each device here. - */ - device_notify(DEVICE_NOTIFIER_THERMAL_GET_SCENARIO, &scenario); if (!scenario) {