Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
[linux/fpc-iii.git] / drivers / edac / edac_module.c
blob9cb082a19d8a7ae2fbd7a2ae146bd3cd98a59618
1 /*
2 * edac_module.c
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: 3.0.0"
20 #ifdef CONFIG_EDAC_DEBUG
22 static int edac_set_debug_level(const char *buf, struct kernel_param *kp)
24 unsigned long val;
25 int ret;
27 ret = kstrtoul(buf, 0, &val);
28 if (ret)
29 return ret;
31 if (val > 4)
32 return -EINVAL;
34 return param_set_int(buf, kp);
37 /* Values of 0 to 4 will generate output */
38 int edac_debug_level = 2;
39 EXPORT_SYMBOL_GPL(edac_debug_level);
41 module_param_call(edac_debug_level, edac_set_debug_level, param_get_int,
42 &edac_debug_level, 0644);
43 MODULE_PARM_DESC(edac_debug_level, "EDAC debug level: [0-4], default: 2");
44 #endif
46 /* scope is to module level only */
47 struct workqueue_struct *edac_workqueue;
50 * edac_op_state_to_string()
52 char *edac_op_state_to_string(int opstate)
54 if (opstate == OP_RUNNING_POLL)
55 return "POLLED";
56 else if (opstate == OP_RUNNING_INTERRUPT)
57 return "INTERRUPT";
58 else if (opstate == OP_RUNNING_POLL_INTR)
59 return "POLL-INTR";
60 else if (opstate == OP_ALLOC)
61 return "ALLOC";
62 else if (opstate == OP_OFFLINE)
63 return "OFFLINE";
65 return "UNKNOWN";
69 * edac_workqueue_setup
70 * initialize the edac work queue for polling operations
72 static int edac_workqueue_setup(void)
74 edac_workqueue = create_singlethread_workqueue("edac-poller");
75 if (edac_workqueue == NULL)
76 return -ENODEV;
77 else
78 return 0;
82 * edac_workqueue_teardown
83 * teardown the edac workqueue
85 static void edac_workqueue_teardown(void)
87 if (edac_workqueue) {
88 flush_workqueue(edac_workqueue);
89 destroy_workqueue(edac_workqueue);
90 edac_workqueue = NULL;
95 * edac_init
96 * module initialization entry point
98 static int __init edac_init(void)
100 int err = 0;
102 edac_printk(KERN_INFO, EDAC_MC, EDAC_VERSION "\n");
105 * Harvest and clear any boot/initialization PCI parity errors
107 * FIXME: This only clears errors logged by devices present at time of
108 * module initialization. We should also do an initial clear
109 * of each newly hotplugged device.
111 edac_pci_clear_parity_errors();
113 err = edac_mc_sysfs_init();
114 if (err)
115 goto err_sysfs;
117 edac_debugfs_init();
119 err = edac_workqueue_setup();
120 if (err) {
121 edac_printk(KERN_ERR, EDAC_MC, "Failure initializing workqueue\n");
122 goto err_wq;
125 return 0;
127 err_wq:
128 edac_debugfs_exit();
129 edac_mc_sysfs_exit();
131 err_sysfs:
132 return err;
136 * edac_exit()
137 * module exit/termination function
139 static void __exit edac_exit(void)
141 edac_dbg(0, "\n");
143 /* tear down the various subsystems */
144 edac_workqueue_teardown();
145 edac_mc_sysfs_exit();
146 edac_debugfs_exit();
150 * Inform the kernel of our entry and exit points
152 subsys_initcall(edac_init);
153 module_exit(edac_exit);
155 MODULE_LICENSE("GPL");
156 MODULE_AUTHOR("Doug Thompson www.softwarebitmaker.com, et al");
157 MODULE_DESCRIPTION("Core library routines for EDAC reporting");