#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/tracefs.h>
#include "trace_dynevent.h"
static DEFINE_MUTEX(dyn_event_ops_mutex);
static LIST_HEAD(dyn_event_ops_list);
int dyn_event_register(struct dyn_event_operations *ops)
if (!ops || !ops->create || !ops->show || !ops->is_busy ||
!ops->free || !ops->match)
INIT_LIST_HEAD(&ops->list);
mutex_lock(&dyn_event_ops_mutex);
list_add_tail(&ops->list, &dyn_event_ops_list);
mutex_unlock(&dyn_event_ops_mutex);
int dyn_event_release(int argc, char **argv, struct dyn_event_operations *type)
struct dyn_event *pos, *n;
char *system = NULL, *event, *p;
event = strchr(argv[0], ':');
mutex_lock(&event_mutex);
for_each_dyn_event_safe(pos, n) {
if (type && type != pos->ops)
if (pos->ops->match(system, event, pos)) {
ret = pos->ops->free(pos);
mutex_unlock(&event_mutex);
static int create_dyn_event(int argc, char **argv)
struct dyn_event_operations *ops;
if (argv[0][0] == '-' || argv[0][0] == '!')
return dyn_event_release(argc, argv, NULL);
mutex_lock(&dyn_event_ops_mutex);
list_for_each_entry(ops, &dyn_event_ops_list, list) {
ret = ops->create(argc, (const char **)argv);
if (!ret || ret != -ECANCELED)
mutex_unlock(&dyn_event_ops_mutex);