]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/edac/edac_module.c
net: caif: spi: fix potential NULL dereference
[net-next-2.6.git] / drivers / edac / edac_module.c
CommitLineData
81d87cb1
DJ
1/*
2 * edac_module.c
3 *
fb3fb206
DT
4 * (C) 2007 www.softwarebitmaker.com
5 *
81d87cb1
DJ
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 *
fb3fb206 10 * Author: Doug Thompson <dougthompson@xmission.com>
81d87cb1
DJ
11 *
12 */
c0d12172 13#include <linux/edac.h>
7c9281d7 14
20bcb7a8 15#include "edac_core.h"
7c9281d7
DT
16#include "edac_module.h"
17
fb3fb206 18#define EDAC_VERSION "Ver: 2.1.0 " __DATE__
7c9281d7
DT
19
20#ifdef CONFIG_EDAC_DEBUG
21/* Values of 0 to 4 will generate output */
8096cfaf 22int edac_debug_level = 2;
7c9281d7
DT
23EXPORT_SYMBOL_GPL(edac_debug_level);
24#endif
25
e27e3dac
DT
26/* scope is to module level only */
27struct workqueue_struct *edac_workqueue;
28
91b99041 29/*
494d0d55 30 * edac_op_state_to_string()
91b99041 31 */
494d0d55 32char *edac_op_state_to_string(int opstate)
91b99041
DJ
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
e27e3dac
DT
48/*
49 * edac_workqueue_setup
50 * initialize the edac work queue for polling operations
51 */
52static 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 */
65static 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
7c9281d7
DT
74/*
75 * edac_init
76 * module initialization entry point
77 */
78static int __init edac_init(void)
79{
e27e3dac
DT
80 int err = 0;
81
fb3fb206 82 edac_printk(KERN_INFO, EDAC_MC, EDAC_VERSION "\n");
7c9281d7
DT
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
079708b9
DT
88 * module initialization. We should also do an initial clear
89 * of each newly hotplugged device.
7c9281d7
DT
90 */
91 edac_pci_clear_parity_errors();
92
8096cfaf
DT
93 /*
94 * now set up the mc_kset under the edac class object
e27e3dac 95 */
8096cfaf
DT
96 err = edac_sysfs_setup_mc_kset();
97 if (err)
30e1f7a8 98 goto error;
7c9281d7 99
8096cfaf 100 /* Setup/Initialize the workq for this core */
e27e3dac
DT
101 err = edac_workqueue_setup();
102 if (err) {
103 edac_printk(KERN_ERR, EDAC_MC, "init WorkQueue failure\n");
8096cfaf 104 goto workq_fail;
7c9281d7
DT
105 }
106
7c9281d7 107 return 0;
e27e3dac
DT
108
109 /* Error teardown stack */
8096cfaf
DT
110workq_fail:
111 edac_sysfs_teardown_mc_kset();
112
052dfb45 113error:
e27e3dac 114 return err;
7c9281d7
DT
115}
116
117/*
118 * edac_exit()
119 * module exit/termination function
120 */
121static void __exit edac_exit(void)
122{
123 debugf0("%s()\n", __func__);
7c9281d7 124
079708b9 125 /* tear down the various subsystems */
e27e3dac 126 edac_workqueue_teardown();
8096cfaf 127 edac_sysfs_teardown_mc_kset();
7c9281d7
DT
128}
129
130/*
131 * Inform the kernel of our entry and exit points
132 */
133module_init(edac_init);
134module_exit(edac_exit);
135
136MODULE_LICENSE("GPL");
137MODULE_AUTHOR("Doug Thompson www.softwarebitmaker.com, et al");
138MODULE_DESCRIPTION("Core library routines for EDAC reporting");
139
140/* refer to *_sysfs.c files for parameters that are exported via sysfs */
141
142#ifdef CONFIG_EDAC_DEBUG
143module_param(edac_debug_level, int, 0644);
144MODULE_PARM_DESC(edac_debug_level, "Debug level");
145#endif