pass: thermal: Send scenario with additional information 10/262410/3
authorDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 30 Jul 2021 07:50:28 +0000 (16:50 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 20 Aug 2021 02:57:26 +0000 (11:57 +0900)
In order to prepare the case that pass can have multiple thermal
monitors, each monitor sends additional information which includes
resource name as a key.

Change-Id: I47b9fca69c9580774ddffd065bf86e4eef09ee56
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
include/pass/device-notifier.h
src/pass/pass-thermal.c
src/thermal/thermal.c

index 2c67f605b4eb27fcf0767098d32fba4dc4e8d369..e1165eaf2efd8bef608463bed74dc656cad47a83 100644 (file)
@@ -37,6 +37,12 @@ struct device_notifier {
        void *user_data;
 };
 
+/* data structure for DEVICE_NOTIFIER_THERMAL */
+struct device_notifier_thermal_data {
+       char *name;
+       char *scenario;
+};
+
 /*
  * This is for internal callback method.
  */
index 5ef9eb3642e2c41ee38f4bd8133adbe1e92e882c..2a122aca92c4b774428d38f6d0c14c393a734a86 100644 (file)
@@ -152,6 +152,7 @@ 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 */
@@ -166,12 +167,15 @@ static int thermal_monitor_func(void *result, void *user_data)
        if (ret < 0)
                return ret;
 
+       thermal_data.name = res->config_data.res_thermal_name;
+       thermal_data.scenario =
+               thermal->scenarios[thermal->curr_scenario_idx].name;
+
        /*
         * Send notification with thermal scenario name according to
         * measured temperature of each h/w resource.
         */
-       device_notify(DEVICE_NOTIFIER_THERMAL,
-               (void *)thermal->scenarios[thermal->curr_scenario_idx].name);
+       device_notify(DEVICE_NOTIFIER_THERMAL, (void *)&thermal_data);
 
        return 0;
 }
index 3551e4653e2f18d7374232e7075f8a0babb8fba0..e4a55495c4e7b5d76d882ca9a3d0be4b5d2bbc77 100644 (file)
@@ -258,7 +258,9 @@ static struct pass_gdbus_signal_info g_gdbus_signal_infos[] = {
  */
 static int thermal_notifier_cb(void *data, void *user_data)
 {
+       struct device_notifier_thermal_data *thermal_data = data;
        GVariant *gvar;
+       const char *scenario;
        int ret;
        int i;
 
@@ -267,27 +269,29 @@ static int thermal_notifier_cb(void *data, void *user_data)
                return 0;
        }
 
-       if (!data)
+       if (!thermal_data)
                return -EINVAL;
 
+       scenario = thermal_data->scenario;
+
        /* Find the available thermal scenario */
        for (i = 0; i < g_thermal->num; i++) {
                if (!g_thermal->list[i].support)
                        continue;
-               if (!strncmp(g_thermal->list[i].name, data, strlen(data)))
+               if (!strncmp(g_thermal->list[i].name, scenario, strlen(scenario)))
                        break;
        }
 
        /* If there is no available thermal scenario, just return */
        if (i >= g_thermal->num) {
-               _I("Not supported \'%s\' scenario", (char*)data);
+               _I("Not supported \'%s\' scenario", scenario);
                return 0;
        }
 
        g_thermal->cur_scenario_idx = i;
 
        /* If there is available thermal scenario, send the broadcast signal */
-       gvar = g_variant_new("(s)", data);
+       gvar = g_variant_new("(s)", scenario);
        ret = pass_gdbus_send_broadcast_signal(PASS_DBUS_THERMAL,
                                        DBUS_THERMAL_PATH,
                                        DBUS_THERMAL_INTERFACE,