#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;
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,
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
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 */
* 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;
* 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;
}