xref: /openbmc/linux/kernel/trace/rv/reactor_printk.c (revision ffcdf473)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <bristot@kernel.org>
4  *
5  * Printk RV reactor:
6  *   Prints the exception msg to the kernel message log.
7  */
8 #include <linux/ftrace.h>
9 #include <linux/tracepoint.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/rv.h>
14 
15 static void rv_printk_reaction(char *msg)
16 {
17 	printk_deferred(msg);
18 }
19 
20 static struct rv_reactor rv_printk = {
21 	.name = "printk",
22 	.description = "prints the exception msg to the kernel message log.",
23 	.react = rv_printk_reaction
24 };
25 
26 static int __init register_react_printk(void)
27 {
28 	rv_register_reactor(&rv_printk);
29 	return 0;
30 }
31 
32 static void __exit unregister_react_printk(void)
33 {
34 	rv_unregister_reactor(&rv_printk);
35 }
36 
37 module_init(register_react_printk);
38 module_exit(unregister_react_printk);
39 
40 MODULE_AUTHOR("Daniel Bristot de Oliveira");
41 MODULE_DESCRIPTION("printk rv reactor: printk if an exception is hit.");
42