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;
}
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) {