edac: Convert debugfX to edac_dbg(X,
[deliverable/linux.git] / drivers / edac / edac_module.c
1 /*
2 * edac_module.c
3 *
4 * (C) 2007 www.softwarebitmaker.com
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 *
10 * Author: Doug Thompson <dougthompson@xmission.com>
11 *
12 */
13 #include <linux/edac.h>
14
15 #include "edac_core.h"
16 #include "edac_module.h"
17
18 #define EDAC_VERSION "Ver: 2.1.0"
19
20 #ifdef CONFIG_EDAC_DEBUG
21 /* Values of 0 to 4 will generate output */
22 int edac_debug_level = 2;
23 EXPORT_SYMBOL_GPL(edac_debug_level);
24 #endif
25
26 /* scope is to module level only */
27 struct workqueue_struct *edac_workqueue;
28
29 /*
30 * edac_op_state_to_string()
31 */
32 char *edac_op_state_to_string(int opstate)
33 {
34 if (opstate == OP_RUNNING_POLL)
35 return "POLLED";
36 else if (opstate == OP_RUNNING_INTERRUPT)
37 return "INTERRUPT";
38 else if (opstate == OP_RUNNING_POLL_INTR)
39 return "POLL-INTR";
40 else if (opstate == OP_ALLOC)
41 return "ALLOC";
42 else if (opstate == OP_OFFLINE)
43 return "OFFLINE";
44
45 return "UNKNOWN";
46 }
47
48 /*
49 * edac_workqueue_setup
50 * initialize the edac work queue for polling operations
51 */
52 static int edac_workqueue_setup(void)
53 {
54 edac_workqueue = create_singlethread_workqueue("edac-poller");
55 if (edac_workqueue == NULL)
56 return -ENODEV;
57 else
58 return 0;
59 }
60
61 /*
62 * edac_workqueue_teardown
63 * teardown the edac workqueue
64 */
65 static void edac_workqueue_teardown(void)
66 {
67 if (edac_workqueue) {
68 flush_workqueue(edac_workqueue);
69 destroy_workqueue(edac_workqueue);
70 edac_workqueue = NULL;
71 }
72 }
73
74 /*
75 * edac_init
76 * module initialization entry point
77 */
78 static int __init edac_init(void)
79 {
80 int err = 0;
81
82 edac_printk(KERN_INFO, EDAC_MC, EDAC_VERSION "\n");
83
84 /*
85 * Harvest and clear any boot/initialization PCI parity errors
86 *
87 * FIXME: This only clears errors logged by devices present at time of
88 * module initialization. We should also do an initial clear
89 * of each newly hotplugged device.
90 */
91 edac_pci_clear_parity_errors();
92
93 err = edac_mc_sysfs_init();
94 if (err)
95 goto error;
96
97 /* Setup/Initialize the workq for this core */
98 err = edac_workqueue_setup();
99 if (err) {
100 edac_printk(KERN_ERR, EDAC_MC, "init WorkQueue failure\n");
101 goto error;
102 }
103
104 return 0;
105
106 error:
107 return err;
108 }
109
110 /*
111 * edac_exit()
112 * module exit/termination function
113 */
114 static void __exit edac_exit(void)
115 {
116 edac_dbg(0, "\n");
117
118 /* tear down the various subsystems */
119 edac_workqueue_teardown();
120 edac_mc_sysfs_exit();
121 }
122
123 /*
124 * Inform the kernel of our entry and exit points
125 */
126 module_init(edac_init);
127 module_exit(edac_exit);
128
129 MODULE_LICENSE("GPL");
130 MODULE_AUTHOR("Doug Thompson www.softwarebitmaker.com, et al");
131 MODULE_DESCRIPTION("Core library routines for EDAC reporting");
132
133 /* refer to *_sysfs.c files for parameters that are exported via sysfs */
134
135 #ifdef CONFIG_EDAC_DEBUG
136 module_param(edac_debug_level, int, 0644);
137 MODULE_PARM_DESC(edac_debug_level, "Debug level");
138 #endif
This page took 0.050976 seconds and 6 git commands to generate.