PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / edac / edac_stub.c
blob9d9e18aefaaa491e2020d55b503bcbbe862a9032
1 /*
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 <bp@alien8.de>
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>
18 #include <linux/device.h>
19 #include <asm/edac.h>
21 int edac_op_state = EDAC_OPSTATE_INVAL;
22 EXPORT_SYMBOL_GPL(edac_op_state);
24 atomic_t edac_handlers = ATOMIC_INIT(0);
25 EXPORT_SYMBOL_GPL(edac_handlers);
27 int edac_err_assert = 0;
28 EXPORT_SYMBOL_GPL(edac_err_assert);
30 static atomic_t edac_subsys_valid = ATOMIC_INIT(0);
32 int edac_report_status = EDAC_REPORTING_ENABLED;
33 EXPORT_SYMBOL_GPL(edac_report_status);
35 static int __init edac_report_setup(char *str)
37 if (!str)
38 return -EINVAL;
40 if (!strncmp(str, "on", 2))
41 set_edac_report_status(EDAC_REPORTING_ENABLED);
42 else if (!strncmp(str, "off", 3))
43 set_edac_report_status(EDAC_REPORTING_DISABLED);
44 else if (!strncmp(str, "force", 5))
45 set_edac_report_status(EDAC_REPORTING_FORCE);
47 return 0;
49 __setup("edac_report=", edac_report_setup);
52 * called to determine if there is an EDAC driver interested in
53 * knowing an event (such as NMI) occurred
55 int edac_handler_set(void)
57 if (edac_op_state == EDAC_OPSTATE_POLL)
58 return 0;
60 return atomic_read(&edac_handlers);
62 EXPORT_SYMBOL_GPL(edac_handler_set);
65 * handler for NMI type of interrupts to assert error
67 void edac_atomic_assert_error(void)
69 edac_err_assert++;
71 EXPORT_SYMBOL_GPL(edac_atomic_assert_error);
74 * sysfs object: /sys/devices/system/edac
75 * need to export to other files
77 struct bus_type edac_subsys = {
78 .name = "edac",
79 .dev_name = "edac",
81 EXPORT_SYMBOL_GPL(edac_subsys);
83 /* return pointer to the 'edac' node in sysfs */
84 struct bus_type *edac_get_sysfs_subsys(void)
86 int err = 0;
88 if (atomic_read(&edac_subsys_valid))
89 goto out;
91 /* create the /sys/devices/system/edac directory */
92 err = subsys_system_register(&edac_subsys, NULL);
93 if (err) {
94 printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
95 return NULL;
98 out:
99 atomic_inc(&edac_subsys_valid);
100 return &edac_subsys;
102 EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys);
104 void edac_put_sysfs_subsys(void)
106 /* last user unregisters it */
107 if (atomic_dec_and_test(&edac_subsys_valid))
108 bus_unregister(&edac_subsys);
110 EXPORT_SYMBOL_GPL(edac_put_sysfs_subsys);