drm/exynos: fix build warnings from ipp fimc
[linux-2.6-block.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.
43aff26c 8 * Borislav Petkov <bp@alien8.de>
30e1f7a8
BP
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>
51990e82 18#include <linux/device.h>
c0d12172
DJ
19#include <asm/edac.h>
20
21int edac_op_state = EDAC_OPSTATE_INVAL;
fb3fb206 22EXPORT_SYMBOL_GPL(edac_op_state);
c0d12172
DJ
23
24atomic_t edac_handlers = ATOMIC_INIT(0);
fb3fb206 25EXPORT_SYMBOL_GPL(edac_handlers);
c0d12172 26
66ee2f94 27int edac_err_assert = 0;
fb3fb206 28EXPORT_SYMBOL_GPL(edac_err_assert);
c0d12172 29
fe5ff8b8 30static atomic_t edac_subsys_valid = ATOMIC_INIT(0);
30e1f7a8 31
fb3fb206
DT
32/*
33 * called to determine if there is an EDAC driver interested in
34 * knowing an event (such as NMI) occurred
35 */
36int edac_handler_set(void)
c0d12172
DJ
37{
38 if (edac_op_state == EDAC_OPSTATE_POLL)
39 return 0;
40
41 return atomic_read(&edac_handlers);
42}
fb3fb206 43EXPORT_SYMBOL_GPL(edac_handler_set);
c0d12172
DJ
44
45/*
46 * handler for NMI type of interrupts to assert error
47 */
fb3fb206 48void edac_atomic_assert_error(void)
c0d12172 49{
66ee2f94 50 edac_err_assert++;
c0d12172 51}
fb3fb206 52EXPORT_SYMBOL_GPL(edac_atomic_assert_error);
30e1f7a8
BP
53
54/*
55 * sysfs object: /sys/devices/system/edac
56 * need to export to other files
57 */
fe5ff8b8 58struct bus_type edac_subsys = {
30e1f7a8 59 .name = "edac",
fe5ff8b8 60 .dev_name = "edac",
30e1f7a8 61};
fe5ff8b8 62EXPORT_SYMBOL_GPL(edac_subsys);
30e1f7a8
BP
63
64/* return pointer to the 'edac' node in sysfs */
fe5ff8b8 65struct bus_type *edac_get_sysfs_subsys(void)
30e1f7a8
BP
66{
67 int err = 0;
68
fe5ff8b8 69 if (atomic_read(&edac_subsys_valid))
30e1f7a8
BP
70 goto out;
71
72 /* create the /sys/devices/system/edac directory */
fe5ff8b8 73 err = subsys_system_register(&edac_subsys, NULL);
30e1f7a8
BP
74 if (err) {
75 printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
76 return NULL;
77 }
78
79out:
fe5ff8b8
KS
80 atomic_inc(&edac_subsys_valid);
81 return &edac_subsys;
30e1f7a8 82}
fe5ff8b8 83EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys);
30e1f7a8 84
fe5ff8b8 85void edac_put_sysfs_subsys(void)
30e1f7a8
BP
86{
87 /* last user unregisters it */
fe5ff8b8
KS
88 if (atomic_dec_and_test(&edac_subsys_valid))
89 bus_unregister(&edac_subsys);
30e1f7a8 90}
fe5ff8b8 91EXPORT_SYMBOL_GPL(edac_put_sysfs_subsys);