Linux 2.6.28.1
[linux/fpc-iii.git] / samples / tracepoints / tracepoint-sample.c
blob4ae4b7fcc04327766145a0483d00720dadc2928a
1 /* tracepoint-sample.c
3 * Executes a tracepoint when /proc/tracepoint-example is opened.
5 * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
7 * This file is released under the GPLv2.
8 * See the file COPYING for more details.
9 */
11 #include <linux/module.h>
12 #include <linux/sched.h>
13 #include <linux/proc_fs.h>
14 #include "tp-samples-trace.h"
16 struct proc_dir_entry *pentry_example;
18 static int my_open(struct inode *inode, struct file *file)
20 int i;
22 trace_subsys_event(inode, file);
23 for (i = 0; i < 10; i++)
24 trace_subsys_eventb();
25 return -EPERM;
28 static struct file_operations mark_ops = {
29 .open = my_open,
32 static int example_init(void)
34 printk(KERN_ALERT "example init\n");
35 pentry_example = proc_create("tracepoint-example", 0444, NULL,
36 &mark_ops);
37 if (!pentry_example)
38 return -EPERM;
39 return 0;
42 static void example_exit(void)
44 printk(KERN_ALERT "example exit\n");
45 remove_proc_entry("tracepoint-example", NULL);
48 module_init(example_init)
49 module_exit(example_exit)
51 MODULE_LICENSE("GPL");
52 MODULE_AUTHOR("Mathieu Desnoyers");
53 MODULE_DESCRIPTION("Tracepoint example");