4 * (C) 2007 www.softwarebitmaker.com
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.
10 * Author: Doug Thompson <dougthompson@xmission.com>
13 #include <linux/edac.h>
15 #include "edac_core.h"
16 #include "edac_module.h"
18 #define EDAC_VERSION "Ver: 2.1.0 " __DATE__
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);
26 /* scope is to module level only */
27 struct workqueue_struct *edac_workqueue;
30 * edac_op_state_to_string()
32 char *edac_op_state_to_string(int opstate)
34 if (opstate == OP_RUNNING_POLL)
36 else if (opstate == OP_RUNNING_INTERRUPT)
38 else if (opstate == OP_RUNNING_POLL_INTR)
40 else if (opstate == OP_ALLOC)
42 else if (opstate == OP_OFFLINE)
49 * edac_workqueue_setup
50 * initialize the edac work queue for polling operations
52 static int edac_workqueue_setup(void)
54 edac_workqueue = create_singlethread_workqueue("edac-poller");
55 if (edac_workqueue == NULL)
62 * edac_workqueue_teardown
63 * teardown the edac workqueue
65 static void edac_workqueue_teardown(void)
68 flush_workqueue(edac_workqueue);
69 destroy_workqueue(edac_workqueue);
70 edac_workqueue = NULL;
76 * module initialization entry point
78 static int __init edac_init(void)
82 edac_printk(KERN_INFO, EDAC_MC, EDAC_VERSION "\n");
85 * Harvest and clear any boot/initialization PCI parity errors
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.
91 edac_pci_clear_parity_errors();
94 * now set up the mc_kset under the edac class object
96 err = edac_sysfs_setup_mc_kset();
100 /* Setup/Initialize the workq for this core */
101 err = edac_workqueue_setup();
103 edac_printk(KERN_ERR, EDAC_MC, "init WorkQueue failure\n");
109 /* Error teardown stack */
111 edac_sysfs_teardown_mc_kset();
119 * module exit/termination function
121 static void __exit edac_exit(void)
123 debugf0("%s()\n", __func__);
125 /* tear down the various subsystems */
126 edac_workqueue_teardown();
127 edac_sysfs_teardown_mc_kset();
131 * Inform the kernel of our entry and exit points
133 module_init(edac_init);
134 module_exit(edac_exit);
136 MODULE_LICENSE("GPL");
137 MODULE_AUTHOR("Doug Thompson www.softwarebitmaker.com, et al");
138 MODULE_DESCRIPTION("Core library routines for EDAC reporting");
140 /* refer to *_sysfs.c files for parameters that are exported via sysfs */
142 #ifdef CONFIG_EDAC_DEBUG
143 module_param(edac_debug_level, int, 0644);
144 MODULE_PARM_DESC(edac_debug_level, "Debug level");