blob: f4d89e008c32adeb7ff02baf572a6edb36707205 [file] [log] [blame]
Mathieu Desnoyers4a089752008-07-18 12:16:16 -04001/* tracepoint-sample.c
2 *
Jody McIntyre0a5d6492009-03-24 16:00:28 -04003 * Executes a tracepoint when /proc/tracepoint-sample is opened.
Mathieu Desnoyers4a089752008-07-18 12:16:16 -04004 *
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/sched.h>
13#include <linux/proc_fs.h>
14#include "tp-samples-trace.h"
15
Mathieu Desnoyers7e066fb2008-11-14 17:47:47 -050016DEFINE_TRACE(subsys_event);
17DEFINE_TRACE(subsys_eventb);
18
Jody McIntyre0a5d6492009-03-24 16:00:28 -040019struct proc_dir_entry *pentry_sample;
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040020
21static int my_open(struct inode *inode, struct file *file)
22{
23 int i;
24
25 trace_subsys_event(inode, file);
26 for (i = 0; i < 10; i++)
27 trace_subsys_eventb();
28 return -EPERM;
29}
30
Alexey Dobriyan828c0952009-10-01 15:43:56 -070031static const struct file_operations mark_ops = {
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040032 .open = my_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +020033 .llseek = noop_llseek,
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040034};
35
Jody McIntyre0a5d6492009-03-24 16:00:28 -040036static int __init sample_init(void)
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040037{
Jody McIntyre0a5d6492009-03-24 16:00:28 -040038 printk(KERN_ALERT "sample init\n");
39 pentry_sample = proc_create("tracepoint-sample", 0444, NULL,
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040040 &mark_ops);
Jody McIntyre0a5d6492009-03-24 16:00:28 -040041 if (!pentry_sample)
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040042 return -EPERM;
43 return 0;
44}
45
Jody McIntyre0a5d6492009-03-24 16:00:28 -040046static void __exit sample_exit(void)
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040047{
Jody McIntyre0a5d6492009-03-24 16:00:28 -040048 printk(KERN_ALERT "sample exit\n");
49 remove_proc_entry("tracepoint-sample", NULL);
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040050}
51
Jody McIntyre0a5d6492009-03-24 16:00:28 -040052module_init(sample_init)
53module_exit(sample_exit)
Mathieu Desnoyers4a089752008-07-18 12:16:16 -040054
55MODULE_LICENSE("GPL");
56MODULE_AUTHOR("Mathieu Desnoyers");
Jody McIntyre0a5d6492009-03-24 16:00:28 -040057MODULE_DESCRIPTION("Tracepoint sample");