blob: 952e411f01f2fc38d4d12426807491b4b5e4f2e8 [file] [log] [blame]
Dave Jiangc0d12172007-07-19 01:49:46 -07001/*
2 * common EDAC components that must be in kernel
3 *
4 * Author: Dave Jiang <djiang@mvista.com>
5 *
Borislav Petkov30e1f7a2010-09-02 17:26:48 +02006 * 2007 (c) MontaVista Software, Inc.
7 * 2010 (c) Advanced Micro Devices Inc.
Borislav Petkov43aff262012-10-29 18:40:09 +01008 * Borislav Petkov <bp@alien8.de>
Borislav Petkov30e1f7a2010-09-02 17:26:48 +02009 *
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.
Dave Jiangc0d12172007-07-19 01:49:46 -070013 *
14 */
15#include <linux/module.h>
16#include <linux/edac.h>
Arun Sharma600634972011-07-26 16:09:06 -070017#include <linux/atomic.h>
Paul Gortmaker51990e82012-01-22 11:23:42 -050018#include <linux/device.h>
Dave Jiangc0d12172007-07-19 01:49:46 -070019
20int edac_op_state = EDAC_OPSTATE_INVAL;
Doug Thompsonfb3fb202007-07-19 01:50:30 -070021EXPORT_SYMBOL_GPL(edac_op_state);
Dave Jiangc0d12172007-07-19 01:49:46 -070022
23atomic_t edac_handlers = ATOMIC_INIT(0);
Doug Thompsonfb3fb202007-07-19 01:50:30 -070024EXPORT_SYMBOL_GPL(edac_handlers);
Dave Jiangc0d12172007-07-19 01:49:46 -070025
Dave Jiang66ee2f92007-07-19 01:49:54 -070026int edac_err_assert = 0;
Doug Thompsonfb3fb202007-07-19 01:50:30 -070027EXPORT_SYMBOL_GPL(edac_err_assert);
Dave Jiangc0d12172007-07-19 01:49:46 -070028
Chen, Gongc700f012013-12-06 01:17:08 -050029int edac_report_status = EDAC_REPORTING_ENABLED;
30EXPORT_SYMBOL_GPL(edac_report_status);
31
32static int __init edac_report_setup(char *str)
33{
34 if (!str)
35 return -EINVAL;
36
37 if (!strncmp(str, "on", 2))
38 set_edac_report_status(EDAC_REPORTING_ENABLED);
39 else if (!strncmp(str, "off", 3))
40 set_edac_report_status(EDAC_REPORTING_DISABLED);
41 else if (!strncmp(str, "force", 5))
42 set_edac_report_status(EDAC_REPORTING_FORCE);
43
44 return 0;
45}
46__setup("edac_report=", edac_report_setup);
47
Doug Thompsonfb3fb202007-07-19 01:50:30 -070048/*
49 * called to determine if there is an EDAC driver interested in
50 * knowing an event (such as NMI) occurred
51 */
52int edac_handler_set(void)
Dave Jiangc0d12172007-07-19 01:49:46 -070053{
54 if (edac_op_state == EDAC_OPSTATE_POLL)
55 return 0;
56
57 return atomic_read(&edac_handlers);
58}
Doug Thompsonfb3fb202007-07-19 01:50:30 -070059EXPORT_SYMBOL_GPL(edac_handler_set);
Dave Jiangc0d12172007-07-19 01:49:46 -070060
61/*
62 * handler for NMI type of interrupts to assert error
63 */
Doug Thompsonfb3fb202007-07-19 01:50:30 -070064void edac_atomic_assert_error(void)
Dave Jiangc0d12172007-07-19 01:49:46 -070065{
Dave Jiang66ee2f92007-07-19 01:49:54 -070066 edac_err_assert++;
Dave Jiangc0d12172007-07-19 01:49:46 -070067}
Doug Thompsonfb3fb202007-07-19 01:50:30 -070068EXPORT_SYMBOL_GPL(edac_atomic_assert_error);