#include <pass/log.h>
#include "pass.h"
+#include "pass-hal.h"
#include "pass-resmon.h"
#include "pass-resmon-internal.h"
/* RESMON_SRC_THERMAL */
static int resmon_thermal_init(struct resmon *monitor)
{
+ struct resmon_result_src_thermal *result;
+
+ if (monitor->result)
+ return 0;
+
+ result = calloc(1, sizeof(*result));
+ if (!result)
+ return -ENOMEM;
+
+ monitor->result = result;
+
return 0;
}
static int resmon_thermal_exit(struct resmon *monitor)
{
+ if (!monitor->result)
+ return 0;
+
+ free(monitor->result);
+ monitor->result = NULL;
+
return 0;
}
static int resmon_thermal_timer_handler(struct resmon *monitor, void *result)
{
+ struct pass_resmon *resmon = monitor->resmon;
+ struct pass_resource *res =
+ container_of(resmon, struct pass_resource, resmon);
+ struct resmon_result_src_thermal *thermal_result = result;
+ int temp;
+
+ if (!thermal_result)
+ return -ENOMEM;
+
+ /* Get temperature of h/w resource */
+ temp = pass_get_temp(res);
+ if (temp < 0)
+ return temp;
+
+ thermal_result->temp = temp;
+
return 0;
}
* the linux kernel standard interface.
*
* Description of result format of resource monitor's source type:
+ * - RESMON_SRC_THERMAL: struct resmon_result_src_thermal
* - RESMON_SRC_CPUHP : struct resmon_result_src_cpuhp
*/
enum resmon_src_type {
RESMON_SRC_CPUHP = 0x2,
};
+/* Result of RESMON_SRC_THERMAL resource monitor */
+struct resmon_result_src_thermal {
+ int temp;
+};
+
/* Result of RESMON_SRC_CPUHP's resource monitor */
struct resmon_result_src_cpuhp {
int64_t time;