Linux 2.6.31.8
[linux/fpc-iii.git] / kernel / trace / trace_nop.c
blob394f94417e2f9edadbfdd449a90f5b8fd9ddd166
1 /*
2 * nop tracer
4 * Copyright (C) 2008 Steven Noonan <steven@uplinklabs.net>
6 */
8 #include <linux/module.h>
9 #include <linux/fs.h>
10 #include <linux/debugfs.h>
11 #include <linux/ftrace.h>
13 #include "trace.h"
15 /* Our two options */
16 enum {
17 TRACE_NOP_OPT_ACCEPT = 0x1,
18 TRACE_NOP_OPT_REFUSE = 0x2
21 /* Options for the tracer (see trace_options file) */
22 static struct tracer_opt nop_opts[] = {
23 /* Option that will be accepted by set_flag callback */
24 { TRACER_OPT(test_nop_accept, TRACE_NOP_OPT_ACCEPT) },
25 /* Option that will be refused by set_flag callback */
26 { TRACER_OPT(test_nop_refuse, TRACE_NOP_OPT_REFUSE) },
27 { } /* Always set a last empty entry */
30 static struct tracer_flags nop_flags = {
31 /* You can check your flags value here when you want. */
32 .val = 0, /* By default: all flags disabled */
33 .opts = nop_opts
36 static struct trace_array *ctx_trace;
38 static void start_nop_trace(struct trace_array *tr)
40 /* Nothing to do! */
43 static void stop_nop_trace(struct trace_array *tr)
45 /* Nothing to do! */
48 static int nop_trace_init(struct trace_array *tr)
50 ctx_trace = tr;
51 start_nop_trace(tr);
52 return 0;
55 static void nop_trace_reset(struct trace_array *tr)
57 stop_nop_trace(tr);
60 /* It only serves as a signal handler and a callback to
61 * accept or refuse tthe setting of a flag.
62 * If you don't implement it, then the flag setting will be
63 * automatically accepted.
65 static int nop_set_flag(u32 old_flags, u32 bit, int set)
68 * Note that you don't need to update nop_flags.val yourself.
69 * The tracing Api will do it automatically if you return 0
71 if (bit == TRACE_NOP_OPT_ACCEPT) {
72 printk(KERN_DEBUG "nop_test_accept flag set to %d: we accept."
73 " Now cat trace_options to see the result\n",
74 set);
75 return 0;
78 if (bit == TRACE_NOP_OPT_REFUSE) {
79 printk(KERN_DEBUG "nop_test_refuse flag set to %d: we refuse."
80 "Now cat trace_options to see the result\n",
81 set);
82 return -EINVAL;
85 return 0;
89 struct tracer nop_trace __read_mostly =
91 .name = "nop",
92 .init = nop_trace_init,
93 .reset = nop_trace_reset,
94 .wait_pipe = poll_wait_pipe,
95 #ifdef CONFIG_FTRACE_SELFTEST
96 .selftest = trace_selftest_startup_nop,
97 #endif
98 .flags = &nop_flags,
99 .set_flag = nop_set_flag