#include <libudev.h>
+#include "pass.h"
+
/**
* @brief Represents the type of resource-monitor.
*/
int (*uevent_handler)(struct resmon *monitor, void *result,
struct udev_device *dev);
/**
- * Instance of uevent subsystem. It will be used for only uevent-based
+ * List of uevent subsystem name. It will be used for only uevent-based
* resource monitor.
*/
- const char *uevent_subsystem;
+ const char *uevent_subsystem[BUFF_MAX];
+ /**
+ * List of uevent device type name. It will be used for only uevent-based
+ * resource monitor.
+ */
+ const char *uevent_devtype[BUFF_MAX];
+
/**
- * Instance of uevent device type. It will be used for only uevent-based
+ * Number of uevent type. It will be used for only uevent-based
* resource monitor.
*/
- const char *uevent_devtype;
+ const int number_of_uevent;
};
/**
.exit = resmon_thermal_exit,
.timer_handler = resmon_thermal_timer_handler,
.uevent_handler = resmon_thermal_uevent_handler,
- .uevent_subsystem = "thermal",
- .uevent_devtype = NULL,
+ .uevent_subsystem = {
+ "thermal",
+ },
+ .uevent_devtype = {
+ NULL,
+ },
+ .number_of_uevent = 1,
};
/**
.exit = resmon_cpuhp_exit,
.timer_handler = resmon_cpuhp_timer_handler,
.uevent_handler = NULL,
- .uevent_subsystem = NULL,
- .uevent_devtype = NULL,
+ .uevent_subsystem = {
+ NULL,
+ },
+ .uevent_devtype = {
+ NULL,
+ },
+ .number_of_uevent = 0,
};
/**
guint gfd;
int ret;
int fd;
+ int i;
/* Initialize the udev-monitor instance and set buffer size */
udev_monitor = udev_monitor_new_from_netlink(g_udev, "kernel");
}
/*
- * At least, either uevent_subsystem or uevent_devtype should be not NULL
+ * Number of uevent subsystem must be more than 0 at least.
*/
- if (!monitor->ops->uevent_subsystem && !monitor->ops->uevent_devtype) {
+ if (monitor->ops->number_of_uevent <= 0) {
_E("failed to add filter due to subsystem/devtype are NULL " \
"(res_name:%s, src_type: 0x%x)\n",
res->config_data.res_name, monitor->src_type);
}
/* Update the kernel's subsystem and devtype for filtering */
- ret = udev_monitor_filter_add_match_subsystem_devtype(
- udev_monitor,
- monitor->ops->uevent_subsystem,
- monitor->ops->uevent_devtype);
- if (ret < 0) {
- _E("failed to add filter with subsystem and devtype " \
- "(res_name:%s, src_type: 0x%x)\n",
- res->config_data.res_name, monitor->src_type);
- goto err_udev_monitor;
+ for (i = 0; i < monitor->ops->number_of_uevent; i++) {
+ ret = udev_monitor_filter_add_match_subsystem_devtype(
+ udev_monitor,
+ monitor->ops->uevent_subsystem[i],
+ monitor->ops->uevent_devtype[i]);
+ if (ret < 0) {
+ _E("failed to add filter with subsystem(%s)/devtype(%s) " \
+ "(res_name:%s, src_type: 0x%x)\n",
+ monitor->ops->uevent_subsystem[i],
+ monitor->ops->uevent_devtype[i],
+ res->config_data.res_name, monitor->src_type);
+ goto err_udev_monitor;
+ }
}
ret = udev_monitor_filter_update(udev_monitor);
if (ret < 0) {
- _E("failed to update filter with subsystem(%s) & devtype(%s) " \
+ for (i = 0; i < monitor->ops->number_of_uevent; i++) {
+ _E("failed to update filter with subsystem(%s)/devtype(%s) " \
"(res_name:%s, src_type: 0x%x)\n",
- monitor->ops->uevent_subsystem,
- monitor->ops->uevent_devtype,
+ monitor->ops->uevent_subsystem[i],
+ monitor->ops->uevent_devtype[i],
res->config_data.res_name, monitor->src_type);
+ }
goto err_udev_monitor;
}