History

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.

Steven Rostedt (Red Hat) committed 13 years ago

Commit da511bf1 parent 1cf4c071 file · +20 −12Browse files

Unified · Split

kernel/trace/trace_events.c+20−12
@@ -1529,6 +1529,24 @@ __register_event(struct ftrace_event_call *call, struct module *mod) · 1528 unmodified lines
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 int1551static 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, · 5 unmodified lines
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, · 8 unmodified lines
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