{                                                                      \
        unregister_trace_##call(ftrace_event_##call);                   \
 }                                                                      \
-
+                                                                       \
+static struct ftrace_event_call event_##call;                          \
+                                                                       \
+static int ftrace_init_event_##call(void)                              \
+{                                                                      \
+       int id;                                                         \
+                                                                       \
+       id = register_ftrace_event(NULL);                               \
+       if (!id)                                                        \
+               return -ENODEV;                                         \
+       event_##call.id = id;                                           \
+       return 0;                                                       \
+}
 
 #undef TRACE_FORMAT
 #define TRACE_FORMAT(call, proto, args, fmt)                           \
 __attribute__((section("_ftrace_events"))) event_##call = {            \
        .name                   = #call,                                \
        .system                 = __stringify(TRACE_SYSTEM),            \
+       .raw_init               = ftrace_init_event_##call,             \
        .regfunc                = ftrace_reg_event_##call,              \
        .unregfunc              = ftrace_unreg_event_##call,            \
 }
 
 
        mutex_lock(&trace_event_mutex);
 
+       if (!event) {
+               ret = next_event_type++;
+               goto out;
+       }
+
        if (!event->type)
                event->type = next_event_type++;
        else if (event->type > __TRACE_LAST_TYPE) {