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