blob: e9e0040ff7be25a9953a65a30293f3b63b386444 [file] [log] [blame]
Steven Rostedt (Red Hat)aad108a2016-06-17 14:50:23 -04001#include <linux/module.h>
2#include <linux/kthread.h>
3#include <linux/irq_work.h>
4
5/* Must not be static to force gcc to consider these non constant */
6char *trace_printk_test_global_str =
7 "This is a dynamic string that will use trace_puts\n";
8
9char *trace_printk_test_global_str_irq =
10 "(irq) This is a dynamic string that will use trace_puts\n";
11
12char *trace_printk_test_global_str_fmt =
13 "%sThis is a %s that will use trace_printk\n";
14
15static struct irq_work irqwork;
16
17static void trace_printk_irq_work(struct irq_work *work)
18{
19 trace_printk("(irq) This is a static string that will use trace_bputs\n");
20 trace_printk(trace_printk_test_global_str_irq);
21
22 trace_printk("(irq) This is a %s that will use trace_bprintk()\n",
23 "static string");
24
25 trace_printk(trace_printk_test_global_str_fmt,
26 "(irq) ", "dynamic string");
27}
28
29static int __init trace_printk_init(void)
30{
31 init_irq_work(&irqwork, trace_printk_irq_work);
32
33 trace_printk("This is a static string that will use trace_bputs\n");
34 trace_printk(trace_printk_test_global_str);
35
36 /* Kick off printing in irq context */
37 irq_work_queue(&irqwork);
38
39 trace_printk("This is a %s that will use trace_bprintk()\n",
40 "static string");
41
42 trace_printk(trace_printk_test_global_str_fmt, "", "dynamic string");
43
44 return 0;
45}
46
47static void __exit trace_printk_exit(void)
48{
49}
50
51module_init(trace_printk_init);
52module_exit(trace_printk_exit);
53
54MODULE_AUTHOR("Steven Rostedt");
55MODULE_DESCRIPTION("trace-printk");
56MODULE_LICENSE("GPL");