#define __DEVICE_NOTIFIER_H__
#include <stdbool.h>
+#include <pass/common.h>
enum device_notifier_type {
DEVICE_NOTIFIER_INIT_DONE,
/* data structure for DEVICE_NOTIFIER_THERMAL */
struct device_notifier_thermal_data {
char *name;
- char *scenario;
+ char scenario[BUFF_MAX];
int priority;
};
struct pass_resource *res = data;
struct pass_thermal *thermal = &res->thermal;
struct device_notifier_thermal_data thermal_data;
+ char *scenario = thermal->scenarios[thermal->curr_scenario_idx].name;
thermal_data.name = res->config_data.res_thermal_name;
- thermal_data.scenario =
- thermal->scenarios[thermal->curr_scenario_idx].name;
+ memcpy(thermal_data.scenario, scenario, BUFF_MAX);
thermal_data.priority = res->config_data.res_thermal_priority;
/*
* Inform the thermal scenario name to
* DEVICE_NOTIFIER_THERMAL_GET_SCENARIO client.
*/
- if (priority < thermal_data->priority || !thermal_data->scenario) {
+ if (priority < thermal_data->priority || strlen(thermal_data->scenario) == 0) {
thermal_data->priority = priority;
- thermal_data->scenario = scenario;
+ memcpy(thermal_data->scenario, scenario, BUFF_MAX);
} else if (priority == thermal_data->priority) {
char *cur = thermal_data->scenario;
int i;
for (i = 0; i < thermal->num_scenarios; i++) {
if (!strncmp(thermal->scenarios[i].name, cur, strlen(cur))) {
if (i > thermal->curr_scenario_idx)
- thermal_data->scenario = scenario;
+ memcpy(thermal_data->scenario, scenario, BUFF_MAX);
break;
}
}
static int thermal_init_done(void *data, void *user_data)
{
struct device_notifier_thermal_data initial_state = {
- .scenario = NULL,
.priority = INT_MAX,
};
char *scenario;
g_thermal->list[i].name);
}
+ memset(&initial_state.scenario, 0, BUFF_MAX);
+
device_notify(DEVICE_NOTIFIER_THERMAL_GET_SCENARIO, &initial_state);
scenario = initial_state.scenario;
priority = initial_state.priority;
- if (!scenario) {
+ if (strlen(scenario) == 0) {
_E("failed to get current scenario for thermal\n");
g_ptr_array_free(g_thermal->resources, TRUE);
free(g_thermal);