Linux 3.3-rc1
[deliverable/linux.git] / drivers / edac / edac_stub.c
CommitLineData
c0d12172
DJ
1/*
2 * common EDAC components that must be in kernel
3 *
4 * Author: Dave Jiang <djiang@mvista.com>
5 *
30e1f7a8
BP
6 * 2007 (c) MontaVista Software, Inc.
7 * 2010 (c) Advanced Micro Devices Inc.
8 * Borislav Petkov <borislav.petkov@amd.com>
9 *
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.
c0d12172
DJ
13 *
14 */
15#include <linux/module.h>
16#include <linux/edac.h>
60063497 17#include <linux/atomic.h>
c0d12172
DJ
18#include <asm/edac.h>
19
20int edac_op_state = EDAC_OPSTATE_INVAL;
fb3fb206 21EXPORT_SYMBOL_GPL(edac_op_state);
c0d12172
DJ
22
23atomic_t edac_handlers = ATOMIC_INIT(0);
fb3fb206 24EXPORT_SYMBOL_GPL(edac_handlers);
c0d12172 25
66ee2f94 26int edac_err_assert = 0;
fb3fb206 27EXPORT_SYMBOL_GPL(edac_err_assert);
c0d12172 28
fe5ff8b8 29static atomic_t edac_subsys_valid = ATOMIC_INIT(0);
30e1f7a8 30
fb3fb206
DT
31/*
32 * called to determine if there is an EDAC driver interested in
33 * knowing an event (such as NMI) occurred
34 */
35int edac_handler_set(void)
c0d12172
DJ
36{
37 if (edac_op_state == EDAC_OPSTATE_POLL)
38 return 0;
39
40 return atomic_read(&edac_handlers);
41}
fb3fb206 42EXPORT_SYMBOL_GPL(edac_handler_set);
c0d12172
DJ
43
44/*
45 * handler for NMI type of interrupts to assert error
46 */
fb3fb206 47void edac_atomic_assert_error(void)
c0d12172 48{
66ee2f94 49 edac_err_assert++;
c0d12172 50}
fb3fb206 51EXPORT_SYMBOL_GPL(edac_atomic_assert_error);
30e1f7a8
BP
52
53/*
54 * sysfs object: /sys/devices/system/edac
55 * need to export to other files
56 */
fe5ff8b8 57struct bus_type edac_subsys = {
30e1f7a8 58 .name = "edac",
fe5ff8b8 59 .dev_name = "edac",
30e1f7a8 60};
fe5ff8b8 61EXPORT_SYMBOL_GPL(edac_subsys);
30e1f7a8
BP
62
63/* return pointer to the 'edac' node in sysfs */
fe5ff8b8 64struct bus_type *edac_get_sysfs_subsys(void)
30e1f7a8
BP
65{
66 int err = 0;
67
fe5ff8b8 68 if (atomic_read(&edac_subsys_valid))
30e1f7a8
BP
69 goto out;
70
71 /* create the /sys/devices/system/edac directory */
fe5ff8b8 72 err = subsys_system_register(&edac_subsys, NULL);
30e1f7a8
BP
73 if (err) {
74 printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
75 return NULL;
76 }
77
78out:
fe5ff8b8
KS
79 atomic_inc(&edac_subsys_valid);
80 return &edac_subsys;
30e1f7a8 81}
fe5ff8b8 82EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys);
30e1f7a8 83
fe5ff8b8 84void edac_put_sysfs_subsys(void)
30e1f7a8
BP
85{
86 /* last user unregisters it */
fe5ff8b8
KS
87 if (atomic_dec_and_test(&edac_subsys_valid))
88 bus_unregister(&edac_subsys);
30e1f7a8 89}
fe5ff8b8 90EXPORT_SYMBOL_GPL(edac_put_sysfs_subsys);
This page took 0.378802 seconds and 5 git commands to generate.