diff options
author | Borislav Petkov <borislav.petkov@amd.com> | 2010-09-02 11:26:48 -0400 |
---|---|---|
committer | Borislav Petkov <bp@amd64.org> | 2010-10-21 08:47:59 -0400 |
commit | 30e1f7a8122145f44f45c95366e27b6bb0b08428 (patch) | |
tree | ad1b549b88319b074505eed41914dd7b70f5434c /drivers/edac/edac_stub.c | |
parent | 7cfd4a87441f5ca3018fdd1f7ad67e8a73a05dc2 (diff) |
EDAC: Export edac sysfs class to users.
Move toplevel sysfs class to the stub and make it available to
non-modularized code too. Add proper refcounting of its users and move
the registration functionality into the reference counting routines.
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac/edac_stub.c')
-rw-r--r-- | drivers/edac/edac_stub.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c index 20b428aa155e..aab970760b75 100644 --- a/drivers/edac/edac_stub.c +++ b/drivers/edac/edac_stub.c | |||
@@ -3,10 +3,13 @@ | |||
3 | * | 3 | * |
4 | * Author: Dave Jiang <djiang@mvista.com> | 4 | * Author: Dave Jiang <djiang@mvista.com> |
5 | * | 5 | * |
6 | * 2007 (c) MontaVista Software, Inc. This file is licensed under | 6 | * 2007 (c) MontaVista Software, Inc. |
7 | * the terms of the GNU General Public License version 2. This program | 7 | * 2010 (c) Advanced Micro Devices Inc. |
8 | * is licensed "as is" without any warranty of any kind, whether express | 8 | * Borislav Petkov <borislav.petkov@amd.com> |
9 | * or implied. | 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. | ||
10 | * | 13 | * |
11 | */ | 14 | */ |
12 | #include <linux/module.h> | 15 | #include <linux/module.h> |
@@ -23,6 +26,8 @@ EXPORT_SYMBOL_GPL(edac_handlers); | |||
23 | int edac_err_assert = 0; | 26 | int edac_err_assert = 0; |
24 | EXPORT_SYMBOL_GPL(edac_err_assert); | 27 | EXPORT_SYMBOL_GPL(edac_err_assert); |
25 | 28 | ||
29 | static atomic_t edac_class_valid = ATOMIC_INIT(0); | ||
30 | |||
26 | /* | 31 | /* |
27 | * called to determine if there is an EDAC driver interested in | 32 | * called to determine if there is an EDAC driver interested in |
28 | * knowing an event (such as NMI) occurred | 33 | * knowing an event (such as NMI) occurred |
@@ -44,3 +49,41 @@ void edac_atomic_assert_error(void) | |||
44 | edac_err_assert++; | 49 | edac_err_assert++; |
45 | } | 50 | } |
46 | EXPORT_SYMBOL_GPL(edac_atomic_assert_error); | 51 | EXPORT_SYMBOL_GPL(edac_atomic_assert_error); |
52 | |||
53 | /* | ||
54 | * sysfs object: /sys/devices/system/edac | ||
55 | * need to export to other files | ||
56 | */ | ||
57 | struct sysdev_class edac_class = { | ||
58 | .name = "edac", | ||
59 | }; | ||
60 | EXPORT_SYMBOL_GPL(edac_class); | ||
61 | |||
62 | /* return pointer to the 'edac' node in sysfs */ | ||
63 | struct sysdev_class *edac_get_sysfs_class(void) | ||
64 | { | ||
65 | int err = 0; | ||
66 | |||
67 | if (atomic_read(&edac_class_valid)) | ||
68 | goto out; | ||
69 | |||
70 | /* create the /sys/devices/system/edac directory */ | ||
71 | err = sysdev_class_register(&edac_class); | ||
72 | if (err) { | ||
73 | printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n"); | ||
74 | return NULL; | ||
75 | } | ||
76 | |||
77 | out: | ||
78 | atomic_inc(&edac_class_valid); | ||
79 | return &edac_class; | ||
80 | } | ||
81 | EXPORT_SYMBOL_GPL(edac_get_sysfs_class); | ||
82 | |||
83 | void edac_put_sysfs_class(void) | ||
84 | { | ||
85 | /* last user unregisters it */ | ||
86 | if (atomic_dec_and_test(&edac_class_valid)) | ||
87 | sysdev_class_unregister(&edac_class); | ||
88 | } | ||
89 | EXPORT_SYMBOL_GPL(edac_put_sysfs_class); | ||