aboutsummaryrefslogtreecommitdiffstats
path: root/samples/markers/marker-example.c
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>2007-10-19 02:41:08 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:55 -0400
commit31155bc03e35a8d2b2551bc2eea3da5791e1b776 (patch)
tree64a82cd692af1dc3672d311f5788e2dc6a56e546 /samples/markers/marker-example.c
parent267c4025f2e198a4e551556a6db31a554ca51814 (diff)
Linux Kernel Markers - Samples
Module example showing how to use the Linux Kernel Markers. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'samples/markers/marker-example.c')
-rw-r--r--samples/markers/marker-example.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/samples/markers/marker-example.c b/samples/markers/marker-example.c
new file mode 100644
index 000000000000..e787c6d16dd7
--- /dev/null
+++ b/samples/markers/marker-example.c
@@ -0,0 +1,54 @@
1/* marker-example.c
2 *
3 * Executes a marker when /proc/marker-example is opened.
4 *
5 * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
6 *
7 * This file is released under the GPLv2.
8 * See the file COPYING for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/marker.h>
13#include <linux/sched.h>
14#include <linux/proc_fs.h>
15
16struct proc_dir_entry *pentry_example;
17
18static int my_open(struct inode *inode, struct file *file)
19{
20 int i;
21
22 trace_mark(subsystem_event, "%d %s", 123, "example string");
23 for (i = 0; i < 10; i++)
24 trace_mark(subsystem_eventb, MARK_NOARGS);
25 return -EPERM;
26}
27
28static struct file_operations mark_ops = {
29 .open = my_open,
30};
31
32static int example_init(void)
33{
34 printk(KERN_ALERT "example init\n");
35 pentry_example = create_proc_entry("marker-example", 0444, NULL);
36 if (pentry_example)
37 pentry_example->proc_fops = &mark_ops;
38 else
39 return -EPERM;
40 return 0;
41}
42
43static void example_exit(void)
44{
45 printk(KERN_ALERT "example exit\n");
46 remove_proc_entry("marker-example", NULL);
47}
48
49module_init(example_init)
50module_exit(example_exit)
51
52MODULE_LICENSE("GPL");
53MODULE_AUTHOR("Mathieu Desnoyers");
54MODULE_DESCRIPTION("Marker example");