Input: bcm5974 - add quad-finger tapping
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / kernel / trace / trace_events_stage_3.h
blob9d2fa78ceccae5973c83c37bdc1e363b214d0d3b
1 /*
2 * Stage 3 of the trace events.
4 * Override the macros in <trace/trace_event_types.h> to include the following:
6 * static void ftrace_event_<call>(proto)
7 * {
8 * event_trace_printk(_RET_IP_, "<call>: " <fmt>);
9 * }
11 * static int ftrace_reg_event_<call>(void)
12 * {
13 * int ret;
15 * ret = register_trace_<call>(ftrace_event_<call>);
16 * if (!ret)
17 * pr_info("event trace: Could not activate trace point "
18 * "probe to <call>");
19 * return ret;
20 * }
22 * static void ftrace_unreg_event_<call>(void)
23 * {
24 * unregister_trace_<call>(ftrace_event_<call>);
25 * }
27 * For those macros defined with TRACE_FORMAT:
29 * static struct ftrace_event_call __used
30 * __attribute__((__aligned__(4)))
31 * __attribute__((section("_ftrace_events"))) event_<call> = {
32 * .name = "<call>",
33 * .regfunc = ftrace_reg_event_<call>,
34 * .unregfunc = ftrace_unreg_event_<call>,
35 * }
38 * For those macros defined with TRACE_EVENT:
40 * static struct ftrace_event_call event_<call>;
42 * static void ftrace_raw_event_<call>(proto)
43 * {
44 * struct ring_buffer_event *event;
45 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
46 * unsigned long irq_flags;
47 * int pc;
49 * local_save_flags(irq_flags);
50 * pc = preempt_count();
52 * event = trace_current_buffer_lock_reserve(event_<call>.id,
53 * sizeof(struct ftrace_raw_<call>),
54 * irq_flags, pc);
55 * if (!event)
56 * return;
57 * entry = ring_buffer_event_data(event);
59 * <assign>; <-- Here we assign the entries by the __field and
60 * __array macros.
62 * trace_current_buffer_unlock_commit(event, irq_flags, pc);
63 * }
65 * static int ftrace_raw_reg_event_<call>(void)
66 * {
67 * int ret;
69 * ret = register_trace_<call>(ftrace_raw_event_<call>);
70 * if (!ret)
71 * pr_info("event trace: Could not activate trace point "
72 * "probe to <call>");
73 * return ret;
74 * }
76 * static void ftrace_unreg_event_<call>(void)
77 * {
78 * unregister_trace_<call>(ftrace_raw_event_<call>);
79 * }
81 * static struct trace_event ftrace_event_type_<call> = {
82 * .trace = ftrace_raw_output_<call>, <-- stage 2
83 * };
85 * static int ftrace_raw_init_event_<call>(void)
86 * {
87 * int id;
89 * id = register_ftrace_event(&ftrace_event_type_<call>);
90 * if (!id)
91 * return -ENODEV;
92 * event_<call>.id = id;
93 * return 0;
94 * }
96 * static struct ftrace_event_call __used
97 * __attribute__((__aligned__(4)))
98 * __attribute__((section("_ftrace_events"))) event_<call> = {
99 * .name = "<call>",
100 * .system = "<system>",
101 * .raw_init = ftrace_raw_init_event_<call>,
102 * .regfunc = ftrace_reg_event_<call>,
103 * .unregfunc = ftrace_unreg_event_<call>,
104 * .show_format = ftrace_format_<call>,
109 #undef TP_FMT
110 #define TP_FMT(fmt, args...) fmt "\n", ##args
112 #ifdef CONFIG_EVENT_PROFILE
113 #define _TRACE_PROFILE(call, proto, args) \
114 static void ftrace_profile_##call(proto) \
116 extern void perf_tpcounter_event(int); \
117 perf_tpcounter_event(event_##call.id); \
120 static int ftrace_profile_enable_##call(struct ftrace_event_call *call) \
122 int ret = 0; \
124 if (!atomic_inc_return(&call->profile_count)) \
125 ret = register_trace_##call(ftrace_profile_##call); \
127 return ret; \
130 static void ftrace_profile_disable_##call(struct ftrace_event_call *call) \
132 if (atomic_add_negative(-1, &call->profile_count)) \
133 unregister_trace_##call(ftrace_profile_##call); \
136 #define _TRACE_PROFILE_INIT(call) \
137 .profile_count = ATOMIC_INIT(-1), \
138 .profile_enable = ftrace_profile_enable_##call, \
139 .profile_disable = ftrace_profile_disable_##call,
141 #else
142 #define _TRACE_PROFILE(call, proto, args)
143 #define _TRACE_PROFILE_INIT(call)
144 #endif
146 #define _TRACE_FORMAT(call, proto, args, fmt) \
147 static void ftrace_event_##call(proto) \
149 event_trace_printk(_RET_IP_, #call ": " fmt); \
152 static int ftrace_reg_event_##call(void) \
154 int ret; \
156 ret = register_trace_##call(ftrace_event_##call); \
157 if (ret) \
158 pr_info("event trace: Could not activate trace point " \
159 "probe to " #call "\n"); \
160 return ret; \
163 static void ftrace_unreg_event_##call(void) \
165 unregister_trace_##call(ftrace_event_##call); \
168 static struct ftrace_event_call event_##call; \
170 static int ftrace_init_event_##call(void) \
172 int id; \
174 id = register_ftrace_event(NULL); \
175 if (!id) \
176 return -ENODEV; \
177 event_##call.id = id; \
178 return 0; \
181 #undef TRACE_FORMAT
182 #define TRACE_FORMAT(call, proto, args, fmt) \
183 _TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \
184 _TRACE_PROFILE(call, PARAMS(proto), PARAMS(args)) \
185 static struct ftrace_event_call __used \
186 __attribute__((__aligned__(4))) \
187 __attribute__((section("_ftrace_events"))) event_##call = { \
188 .name = #call, \
189 .system = __stringify(TRACE_SYSTEM), \
190 .raw_init = ftrace_init_event_##call, \
191 .regfunc = ftrace_reg_event_##call, \
192 .unregfunc = ftrace_unreg_event_##call, \
193 _TRACE_PROFILE_INIT(call) \
196 #undef __entry
197 #define __entry entry
199 #undef TRACE_EVENT
200 #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
201 _TRACE_PROFILE(call, PARAMS(proto), PARAMS(args)) \
203 static struct ftrace_event_call event_##call; \
205 static void ftrace_raw_event_##call(proto) \
207 struct ftrace_event_call *call = &event_##call; \
208 struct ring_buffer_event *event; \
209 struct ftrace_raw_##call *entry; \
210 unsigned long irq_flags; \
211 int pc; \
213 local_save_flags(irq_flags); \
214 pc = preempt_count(); \
216 event = trace_current_buffer_lock_reserve(event_##call.id, \
217 sizeof(struct ftrace_raw_##call), \
218 irq_flags, pc); \
219 if (!event) \
220 return; \
221 entry = ring_buffer_event_data(event); \
223 assign; \
225 if (call->preds && !filter_match_preds(call, entry)) \
226 ring_buffer_event_discard(event); \
228 trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \
232 static int ftrace_raw_reg_event_##call(void) \
234 int ret; \
236 ret = register_trace_##call(ftrace_raw_event_##call); \
237 if (ret) \
238 pr_info("event trace: Could not activate trace point " \
239 "probe to " #call "\n"); \
240 return ret; \
243 static void ftrace_raw_unreg_event_##call(void) \
245 unregister_trace_##call(ftrace_raw_event_##call); \
248 static struct trace_event ftrace_event_type_##call = { \
249 .trace = ftrace_raw_output_##call, \
250 }; \
252 static int ftrace_raw_init_event_##call(void) \
254 int id; \
256 id = register_ftrace_event(&ftrace_event_type_##call); \
257 if (!id) \
258 return -ENODEV; \
259 event_##call.id = id; \
260 INIT_LIST_HEAD(&event_##call.fields); \
261 return 0; \
264 static struct ftrace_event_call __used \
265 __attribute__((__aligned__(4))) \
266 __attribute__((section("_ftrace_events"))) event_##call = { \
267 .name = #call, \
268 .system = __stringify(TRACE_SYSTEM), \
269 .raw_init = ftrace_raw_init_event_##call, \
270 .regfunc = ftrace_raw_reg_event_##call, \
271 .unregfunc = ftrace_raw_unreg_event_##call, \
272 .show_format = ftrace_format_##call, \
273 .define_fields = ftrace_define_fields_##call, \
274 _TRACE_PROFILE_INIT(call) \
277 #include <trace/trace_event_types.h>
279 #undef _TRACE_PROFILE
280 #undef _TRACE_PROFILE_INIT