src/resource-manager/resource-manager.h
src/resource-manager/resource-type.h
src/resource-manager/resource-device.h
+ src/resource-manager/resource-listener.h
)
# CHECK PKG
--- /dev/null
+/*
+ * Copyright (c) 2023 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.
+ */
+
+#ifndef __RESOURCE_LISTENER_H__
+#define __RESOURCE_LISTENER_H__
+
+enum syscommon_resman_listener_type {
+ SYSCOMMON_RESMAN_LISTENER_TYPE_UNKNOWN,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_EPOLL,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_UEVENT,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_TIMER,
+ SYSCOMMON_RESMAN_LISTENER_TYPE_MAX,
+};
+
+#endif
goto err;
}
+ if (resource->attrs[i].listener_ops.init) {
+ ret = resource->attrs[i].listener_ops.init(resource_id, &resource->attrs[i]);
+ if (ret < 0)
+ goto err;
+ }
+
/*
* In resource monitor, each resource has a lot of attributes, but
* only updated attributes are selected by clients on demand. So,
if (!(resource->attrs[i].id & interest_mask))
continue;
+ if (resource->attrs[i].listener_ops.exit)
+ resource->attrs[i].listener_ops.exit(resource_id, &resource->attrs[i]);
+
attr_value = get_resource_attr_value(resource, resource->attrs[i].id);
if (!attr_value)
continue;
if (!(resource->attrs[i].id & interest_mask))
continue;
+ if (resource->attrs[i].listener_ops.exit)
+ resource->attrs[i].listener_ops.exit(resource->id, &resource->attrs[i]);
+
attr_value = get_resource_attr_value(resource, resource->attrs[i].id);
if (!attr_value)
return -EINVAL;
#define SYSCOMMON_RESMAN_BUFF_MAX 255
+enum syscommon_resman_listener_type;
+
struct syscommon_resman_resource_attribute;
struct syscommon_resman_resource_control;
const struct syscommon_resman_resource_attribute *attr);
};
+struct syscommon_resman_resource_attribute_listener_ops {
+ int (*init)(int resource_id, const struct syscommon_resman_resource_attribute *attr);
+ void (*exit)(int resource_id, const struct syscommon_resman_resource_attribute *attr);
+ void (*action)(int resource_id, const struct syscommon_resman_resource_attribute *attr,
+ void *param, enum syscommon_resman_listener_type listener_type);
+};
+
struct syscommon_resman_resource_attribute {
const char name[SYSCOMMON_RESMAN_BUFF_MAX];
const u_int64_t id;
const int type;
const u_int64_t flag;
const struct syscommon_resman_resource_attribute_ops ops;
+ const struct syscommon_resman_resource_attribute_listener_ops listener_ops;
};
struct syscommon_resman_resource_control_ops {