Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
edac_stub.c
Go to the documentation of this file.
1 /*
2  * common EDAC components that must be in kernel
3  *
4  * Author: Dave Jiang <[email protected]>
5  *
6  * 2007 (c) MontaVista Software, Inc.
7  * 2010 (c) Advanced Micro Devices Inc.
8  * Borislav Petkov <[email protected]>
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.
13  *
14  */
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>
20 
23 
25 EXPORT_SYMBOL_GPL(edac_handlers);
26 
29 
30 static atomic_t edac_subsys_valid = ATOMIC_INIT(0);
31 
32 /*
33  * called to determine if there is an EDAC driver interested in
34  * knowing an event (such as NMI) occurred
35  */
37 {
39  return 0;
40 
41  return atomic_read(&edac_handlers);
42 }
44 
45 /*
46  * handler for NMI type of interrupts to assert error
47  */
49 {
51 }
53 
54 /*
55  * sysfs object: /sys/devices/system/edac
56  * need to export to other files
57  */
59  .name = "edac",
60  .dev_name = "edac",
61 };
62 EXPORT_SYMBOL_GPL(edac_subsys);
63 
64 /* return pointer to the 'edac' node in sysfs */
66 {
67  int err = 0;
68 
69  if (atomic_read(&edac_subsys_valid))
70  goto out;
71 
72  /* create the /sys/devices/system/edac directory */
73  err = subsys_system_register(&edac_subsys, NULL);
74  if (err) {
75  printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
76  return NULL;
77  }
78 
79 out:
80  atomic_inc(&edac_subsys_valid);
81  return &edac_subsys;
82 }
84 
86 {
87  /* last user unregisters it */
88  if (atomic_dec_and_test(&edac_subsys_valid))
89  bus_unregister(&edac_subsys);
90 }