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>
16 #include "edac_module.h"
18 #define EDAC_VERSION "Ver: 3.0.0"
20 #ifdef CONFIG_EDAC_DEBUG
22 static int edac_set_debug_level(const char *buf,
23 const struct kernel_param *kp)
28 ret = kstrtoul(buf, 0, &val);
35 return param_set_int(buf, kp);
38 /* Values of 0 to 4 will generate output */
39 int edac_debug_level = 2;
40 EXPORT_SYMBOL_GPL(edac_debug_level);
42 module_param_call(edac_debug_level, edac_set_debug_level, param_get_int,
43 &edac_debug_level, 0644);
44 MODULE_PARM_DESC(edac_debug_level, "EDAC debug level: [0-4], default: 2");
48 * edac_op_state_to_string()
50 char *edac_op_state_to_string(int opstate)
52 if (opstate == OP_RUNNING_POLL)
54 else if (opstate == OP_RUNNING_INTERRUPT)
56 else if (opstate == OP_RUNNING_POLL_INTR)
58 else if (opstate == OP_ALLOC)
60 else if (opstate == OP_OFFLINE)
67 * sysfs object: /sys/devices/system/edac
68 * need to export to other files
70 static struct bus_type edac_subsys = {
75 static int edac_subsys_init(void)
79 /* create the /sys/devices/system/edac directory */
80 err = subsys_system_register(&edac_subsys, NULL);
82 printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
87 static void edac_subsys_exit(void)
89 bus_unregister(&edac_subsys);
92 /* return pointer to the 'edac' node in sysfs */
93 struct bus_type *edac_get_sysfs_subsys(void)
97 EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys);
100 * module initialization entry point
102 static int __init edac_init(void)
106 edac_printk(KERN_INFO, EDAC_MC, EDAC_VERSION "\n");
108 err = edac_subsys_init();
113 * Harvest and clear any boot/initialization PCI parity errors
115 * FIXME: This only clears errors logged by devices present at time of
116 * module initialization. We should also do an initial clear
117 * of each newly hotplugged device.
119 edac_pci_clear_parity_errors();
121 err = edac_mc_sysfs_init();
127 err = edac_workqueue_setup();
129 edac_printk(KERN_ERR, EDAC_MC, "Failure initializing workqueue\n");
137 edac_mc_sysfs_exit();
147 * module exit/termination function
149 static void __exit edac_exit(void)
153 /* tear down the various subsystems */
154 edac_workqueue_teardown();
155 edac_mc_sysfs_exit();
161 * Inform the kernel of our entry and exit points
163 subsys_initcall(edac_init);
164 module_exit(edac_exit);
166 MODULE_LICENSE("GPL");
167 MODULE_AUTHOR("Doug Thompson www.softwarebitmaker.com, et al");
168 MODULE_DESCRIPTION("Core library routines for EDAC reporting");