goto out;
 }
 
+static int destroy_synth_event(struct synth_event *se)
+{
+       int ret;
+
+       if (se->ref)
+               ret = -EBUSY;
+       else {
+               ret = unregister_synth_event(se);
+               if (!ret) {
+                       dyn_event_remove(&se->devent);
+                       free_synth_event(se);
+               }
+       }
+
+       return ret;
+}
+
+/**
+ * synth_event_delete - Delete a synthetic event
+ * @event_name: The name of the new sythetic event
+ *
+ * Delete a synthetic event that was created with synth_event_create().
+ *
+ * Return: 0 if successful, error otherwise.
+ */
+int synth_event_delete(const char *event_name)
+{
+       struct synth_event *se = NULL;
+       int ret = -ENOENT;
+
+       mutex_lock(&event_mutex);
+       se = find_synth_event(event_name);
+       if (se)
+               ret = destroy_synth_event(se);
+       mutex_unlock(&event_mutex);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(synth_event_delete);
+
 static int create_or_delete_synth_event(int argc, char **argv)
 {
        const char *name = argv[0];
-       struct synth_event *event = NULL;
        int ret;
 
        /* trace_run_command() ensures argc != 0 */
        if (name[0] == '!') {
-               mutex_lock(&event_mutex);
-               event = find_synth_event(name + 1);
-               if (event) {
-                       if (event->ref)
-                               ret = -EBUSY;
-                       else {
-                               ret = unregister_synth_event(event);
-                               if (!ret) {
-                                       dyn_event_remove(&event->devent);
-                                       free_synth_event(event);
-                               }
-                       }
-               } else
-                       ret = -ENOENT;
-               mutex_unlock(&event_mutex);
+               ret = synth_event_delete(name + 1);
                return ret;
        }