2 * common EDAC components that must be in kernel
4 * Author: Dave Jiang <djiang@mvista.com>
6 * 2007 (c) MontaVista Software, Inc.
7 * 2010 (c) Advanced Micro Devices Inc.
8 * Borislav Petkov <borislav.petkov@amd.com>
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
15 #include <linux/module.h>
16 #include <linux/edac.h>
17 #include <linux/atomic.h>
20 int edac_op_state
= EDAC_OPSTATE_INVAL
;
21 EXPORT_SYMBOL_GPL(edac_op_state
);
23 atomic_t edac_handlers
= ATOMIC_INIT(0);
24 EXPORT_SYMBOL_GPL(edac_handlers
);
26 int edac_err_assert
= 0;
27 EXPORT_SYMBOL_GPL(edac_err_assert
);
29 static atomic_t edac_subsys_valid
= ATOMIC_INIT(0);
32 * called to determine if there is an EDAC driver interested in
33 * knowing an event (such as NMI) occurred
35 int edac_handler_set(void)
37 if (edac_op_state
== EDAC_OPSTATE_POLL
)
40 return atomic_read(&edac_handlers
);
42 EXPORT_SYMBOL_GPL(edac_handler_set
);
45 * handler for NMI type of interrupts to assert error
47 void edac_atomic_assert_error(void)
51 EXPORT_SYMBOL_GPL(edac_atomic_assert_error
);
54 * sysfs object: /sys/devices/system/edac
55 * need to export to other files
57 struct bus_type edac_subsys
= {
61 EXPORT_SYMBOL_GPL(edac_subsys
);
63 /* return pointer to the 'edac' node in sysfs */
64 struct bus_type
*edac_get_sysfs_subsys(void)
68 if (atomic_read(&edac_subsys_valid
))
71 /* create the /sys/devices/system/edac directory */
72 err
= subsys_system_register(&edac_subsys
, NULL
);
74 printk(KERN_ERR
"Error registering toplevel EDAC sysfs dir\n");
79 atomic_inc(&edac_subsys_valid
);
82 EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys
);
84 void edac_put_sysfs_subsys(void)
86 /* last user unregisters it */
87 if (atomic_dec_and_test(&edac_subsys_valid
))
88 bus_unregister(&edac_subsys
);
90 EXPORT_SYMBOL_GPL(edac_put_sysfs_subsys
);