1 #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 */ 6 char *trace_printk_test_global_str = 7 "This is a dynamic string that will use trace_puts\n"; 8 9 char *trace_printk_test_global_str_irq = 10 "(irq) This is a dynamic string that will use trace_puts\n"; 11 12 char *trace_printk_test_global_str_fmt = 13 "%sThis is a %s that will use trace_printk\n"; 14 15 static struct irq_work irqwork; 16 trace_printk_irq_work(struct irq_work * work)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 trace_printk_init(void)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 trace_printk_exit(void)47static void __exit trace_printk_exit(void) 48 { 49 } 50 51 module_init(trace_printk_init); 52 module_exit(trace_printk_exit); 53 54 MODULE_AUTHOR("Steven Rostedt"); 55 MODULE_DESCRIPTION("trace-printk"); 56 MODULE_LICENSE("GPL"); 57