--- /dev/null
+/*
+ * PASS (Power Aware System Service) Resource Monitor's source implementation
+ *
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <pass/log.h>
+
+#include "pass.h"
+#include "pass-resmon.h"
+#include "pass-resmon-internal.h"
+
+/* RESMON_SRC_THERMAL */
+static int resmon_thermal_init(struct resmon *monitor)
+{
+ return 0;
+}
+
+static int resmon_thermal_exit(struct resmon *monitor)
+{
+ return 0;
+}
+
+static int resmon_thermal_timer_handler(struct resmon *monitor, void *result)
+{
+ return 0;
+}
+
+/* RESMON_SRC_CPUHP */
+static int resmon_cpuhp_init(struct resmon *monitor)
+{
+ return 0;
+}
+
+static int resmon_cpuhp_exit(struct resmon *monitor)
+{
+ return 0;
+}
+
+static int resmon_cpuhp_timer_handler(struct resmon *monitor, void *result)
+{
+ return 0;
+}
+
+struct resmon_ops thermal_src_ops = {
+ .init = resmon_thermal_init,
+ .exit = resmon_thermal_exit,
+ .timer_handler = resmon_thermal_timer_handler,
+};
+
+struct resmon_ops cpuhp_src_ops = {
+ .init = resmon_cpuhp_init,
+ .exit = resmon_cpuhp_exit,
+ .timer_handler = resmon_cpuhp_timer_handler,
+};
+
+struct resmon_ops *resmon_get_ops(enum resmon_src_type src_type)
+{
+ switch (src_type) {
+ case RESMON_SRC_THERMAL:
+ return &thermal_src_ops;
+ case RESMON_SRC_CPUHP:
+ return &cpuhp_src_ops;;
+ default:
+ return NULL;
+ }
+}
#include "pass-resmon.h"
#include "pass-resmon-internal.h"
+extern struct resmon_ops *resmon_get_ops(enum resmon_src_type src_type);
+
uint64 available_resmon_timer[] = {
[PASS_RESOURCE_UNKNOWN] = 0,
[PASS_RESOURCE_CPU_ID] = RESMON_SRC_THERMAL
monitor->user_func = user_func;
monitor->user_data = user_data;
- /* TODO: Get instance of struct resmon_ops accoring to resmon_src_type */
+ /* Get instance of struct resmon_ops accoring to resmon_src_type */
+ monitor->ops = resmon_get_ops(src_type);
+ if (!monitor->ops) {
+ ret = -EINVAL;
+ goto err;
+ }
/* Add timer-based resource monitor */
ret = resmon_timer_add(monitor, timer_interval);