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