aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2013-05-09 15:00:07 -0400
committerSteven Rostedt <rostedt@goodmis.org>2013-05-09 20:14:49 -0400
commitda511bf33e47ea1f33f4b672f7da166d2a1b8a91 (patch)
tree3e514023cb9fd7f91c54e0b952ee5c47b76b945a
parent1cf4c0732db3cd3c49cadbc60ff6bda08604e6fa (diff)
tracing: Add helper function trace_create_new_event() to remove duplicate code
Both __trace_add_new_event() and __trace_early_add_new_event() do basically the same thing, except that __trace_add_new_event() does a little more. Instead of having duplicate code between the two functions, add a helper function trace_create_new_event() that both can use. This will help against having bugs fixed in one function but not the other. Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel/trace/trace_events.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 8be1224046f8..7a0cf68027cc 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1529,6 +1529,24 @@ __register_event(struct ftrace_event_call *call, struct module *mod)
1529 return 0; 1529 return 0;
1530} 1530}
1531 1531
1532static struct ftrace_event_file *
1533trace_create_new_event(struct ftrace_event_call *call,
1534 struct trace_array *tr)
1535{
1536 struct ftrace_event_file *file;
1537
1538 file = kmem_cache_alloc(file_cachep, GFP_TRACE);
1539 if (!file)
1540 return NULL;
1541
1542 file->event_call = call;
1543 file->tr = tr;
1544 atomic_set(&file->sm_ref, 0);
1545 list_add(&file->list, &tr->events);
1546
1547 return file;
1548}
1549
1532/* Add an event to a trace directory */ 1550/* Add an event to a trace directory */
1533static int 1551static int
1534__trace_add_new_event(struct ftrace_event_call *call, 1552__trace_add_new_event(struct ftrace_event_call *call,
@@ -1540,15 +1558,10 @@ __trace_add_new_event(struct ftrace_event_call *call,
1540{ 1558{
1541 struct ftrace_event_file *file; 1559 struct ftrace_event_file *file;
1542 1560
1543 file = kmem_cache_alloc(file_cachep, GFP_TRACE); 1561 file = trace_create_new_event(call, tr);
1544 if (!file) 1562 if (!file)
1545 return -ENOMEM; 1563 return -ENOMEM;
1546 1564
1547 file->event_call = call;
1548 file->tr = tr;
1549 atomic_set(&file->sm_ref, 0);
1550 list_add(&file->list, &tr->events);
1551
1552 return event_create_dir(tr->event_dir, file, id, enable, filter, format); 1565 return event_create_dir(tr->event_dir, file, id, enable, filter, format);
1553} 1566}
1554 1567
@@ -1563,15 +1576,10 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
1563{ 1576{
1564 struct ftrace_event_file *file; 1577 struct ftrace_event_file *file;
1565 1578
1566 file = kmem_cache_alloc(file_cachep, GFP_TRACE); 1579 file = trace_create_new_event(call, tr);
1567 if (!file) 1580 if (!file)
1568 return -ENOMEM; 1581 return -ENOMEM;
1569 1582
1570 file->event_call = call;
1571 file->tr = tr;
1572 atomic_set(&file->sm_ref, 0);
1573 list_add(&file->list, &tr->events);
1574
1575 return 0; 1583 return 0;
1576} 1584}
1577 1585