drm/tegra: Implement syncpoint management UAPI
[linux-2.6-microblaze.git] / kernel / tracepoint.c
index 9f478d2..976bf8c 100644 (file)
@@ -273,7 +273,8 @@ static void tracepoint_update_call(struct tracepoint *tp, struct tracepoint_func
  * Add the probe function to a tracepoint.
  */
 static int tracepoint_add_func(struct tracepoint *tp,
-                              struct tracepoint_func *func, int prio)
+                              struct tracepoint_func *func, int prio,
+                              bool warn)
 {
        struct tracepoint_func *old, *tp_funcs;
        int ret;
@@ -288,7 +289,7 @@ static int tracepoint_add_func(struct tracepoint *tp,
                        lockdep_is_held(&tracepoints_mutex));
        old = func_add(&tp_funcs, func, prio);
        if (IS_ERR(old)) {
-               WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM);
+               WARN_ON_ONCE(warn && PTR_ERR(old) != -ENOMEM);
                return PTR_ERR(old);
        }
 
@@ -343,6 +344,32 @@ static int tracepoint_remove_func(struct tracepoint *tp,
        return 0;
 }
 
+/**
+ * tracepoint_probe_register_prio_may_exist -  Connect a probe to a tracepoint with priority
+ * @tp: tracepoint
+ * @probe: probe handler
+ * @data: tracepoint data
+ * @prio: priority of this function over other registered functions
+ *
+ * Same as tracepoint_probe_register_prio() except that it will not warn
+ * if the tracepoint is already registered.
+ */
+int tracepoint_probe_register_prio_may_exist(struct tracepoint *tp, void *probe,
+                                            void *data, int prio)
+{
+       struct tracepoint_func tp_func;
+       int ret;
+
+       mutex_lock(&tracepoints_mutex);
+       tp_func.func = probe;
+       tp_func.data = data;
+       tp_func.prio = prio;
+       ret = tracepoint_add_func(tp, &tp_func, prio, false);
+       mutex_unlock(&tracepoints_mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(tracepoint_probe_register_prio_may_exist);
+
 /**
  * tracepoint_probe_register_prio -  Connect a probe to a tracepoint with priority
  * @tp: tracepoint
@@ -366,7 +393,7 @@ int tracepoint_probe_register_prio(struct tracepoint *tp, void *probe,
        tp_func.func = probe;
        tp_func.data = data;
        tp_func.prio = prio;
-       ret = tracepoint_add_func(tp, &tp_func, prio);
+       ret = tracepoint_add_func(tp, &tp_func, prio, true);
        mutex_unlock(&tracepoints_mutex);
        return ret;
 }