tools lib traceevent: Add pevent_unregister_print_function()
authorNamhyung Kim <namhyung@kernel.org>
Thu, 16 Jan 2014 02:31:08 +0000 (11:31 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 16 Jan 2014 19:26:24 +0000 (16:26 -0300)
When a plugin unloaded it needs to unregister its print handler from
pevent.

So add an unregister function to do it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1389839478-5887-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/traceevent/event-parse.c
tools/lib/traceevent/event-parse.h

index d1973cb8388bfc6857a91c064d3d79ebebbb489a..1587ea392ad6d83acb0de14b1701db12fa4fc95c 100644 (file)
@@ -5560,6 +5560,29 @@ int pevent_register_print_function(struct pevent *pevent,
        return ret;
 }
 
+/**
+ * pevent_unregister_print_function - unregister a helper function
+ * @pevent: the handle to the pevent
+ * @func: the function to process the helper function
+ * @name: the name of the helper function
+ *
+ * This function removes existing print handler for function @name.
+ *
+ * Returns 0 if the handler was removed successully, -1 otherwise.
+ */
+int pevent_unregister_print_function(struct pevent *pevent,
+                                    pevent_func_handler func, char *name)
+{
+       struct pevent_function_handler *func_handle;
+
+       func_handle = find_func_handler(pevent, name);
+       if (func_handle && func_handle->func == func) {
+               remove_func_handler(pevent, name);
+               return 0;
+       }
+       return -1;
+}
+
 static struct event_format *pevent_search_event(struct pevent *pevent, int id,
                                                const char *sys_name,
                                                const char *event_name)
index c48acfbc6230957b99cd52e9de1c9b0ea51bac56..791c539374c726b7e4d3ad8f6f75aad575692787 100644 (file)
@@ -631,6 +631,8 @@ int pevent_register_print_function(struct pevent *pevent,
                                   pevent_func_handler func,
                                   enum pevent_func_arg_type ret_type,
                                   char *name, ...);
+int pevent_unregister_print_function(struct pevent *pevent,
+                                    pevent_func_handler func, char *name);
 
 struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
 struct format_field *pevent_find_field(struct event_format *event, const char *name);