]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - samples/markers/marker-example.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/czankel/xtens...
[mirror_ubuntu-artful-kernel.git] / samples / markers / marker-example.c
CommitLineData
31155bc0
MD
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
cc9f2f8f
MD
22 trace_mark(subsystem_event, "integer %d string %s", 123,
23 "example string");
31155bc0
MD
24 for (i = 0; i < 10; i++)
25 trace_mark(subsystem_eventb, MARK_NOARGS);
26 return -EPERM;
27}
28
29static struct file_operations mark_ops = {
30 .open = my_open,
31};
32
33static int example_init(void)
34{
35 printk(KERN_ALERT "example init\n");
36 pentry_example = create_proc_entry("marker-example", 0444, NULL);
37 if (pentry_example)
38 pentry_example->proc_fops = &mark_ops;
39 else
40 return -EPERM;
41 return 0;
42}
43
44static void example_exit(void)
45{
46 printk(KERN_ALERT "example exit\n");
47 remove_proc_entry("marker-example", NULL);
48}
49
50module_init(example_init)
51module_exit(example_exit)
52
53MODULE_LICENSE("GPL");
54MODULE_AUTHOR("Mathieu Desnoyers");
55MODULE_DESCRIPTION("Marker example");