3 * Connects two functions to marker call sites.
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.
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/marker.h>
15 #include <asm/atomic.h>
20 marker_probe_func
*probe_func
;
23 void probe_subsystem_event(void *probe_data
, void *call_data
,
24 const char *format
, va_list *args
)
31 value
= va_arg(*args
, typeof(value
));
32 mystr
= va_arg(*args
, typeof(mystr
));
35 printk(KERN_INFO
"Value %u, string %s\n", value
, mystr
);
37 /* or count, check rights, serialize data in a buffer */
40 atomic_t eventb_count
= ATOMIC_INIT(0);
42 void probe_subsystem_eventb(void *probe_data
, void *call_data
,
43 const char *format
, va_list *args
)
45 /* Increment counter */
46 atomic_inc(&eventb_count
);
49 static struct probe_data probe_array
[] =
51 { .name
= "subsystem_event",
52 .format
= "integer %d string %s",
53 .probe_func
= probe_subsystem_event
},
54 { .name
= "subsystem_eventb",
55 .format
= MARK_NOARGS
,
56 .probe_func
= probe_subsystem_eventb
},
59 static int __init
probe_init(void)
64 for (i
= 0; i
< ARRAY_SIZE(probe_array
); i
++) {
65 result
= marker_probe_register(probe_array
[i
].name
,
66 probe_array
[i
].format
,
67 probe_array
[i
].probe_func
, &probe_array
[i
]);
69 printk(KERN_INFO
"Unable to register probe %s\n",
75 static void __exit
probe_fini(void)
79 for (i
= 0; i
< ARRAY_SIZE(probe_array
); i
++)
80 marker_probe_unregister(probe_array
[i
].name
,
81 probe_array
[i
].probe_func
, &probe_array
[i
]);
82 printk(KERN_INFO
"Number of event b : %u\n",
83 atomic_read(&eventb_count
));
86 module_init(probe_init
);
87 module_exit(probe_fini
);
89 MODULE_LICENSE("GPL");
90 MODULE_AUTHOR("Mathieu Desnoyers");
91 MODULE_DESCRIPTION("SUBSYSTEM Probe");