edac_stub.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * common EDAC components that must be in kernel
  3. *
  4. * Author: Dave Jiang <djiang@mvista.com>
  5. *
  6. * 2007 (c) MontaVista Software, Inc.
  7. * 2010 (c) Advanced Micro Devices Inc.
  8. * Borislav Petkov <borislav.petkov@amd.com>
  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. int edac_op_state = EDAC_OPSTATE_INVAL;
  21. EXPORT_SYMBOL_GPL(edac_op_state);
  22. atomic_t edac_handlers = ATOMIC_INIT(0);
  23. EXPORT_SYMBOL_GPL(edac_handlers);
  24. int edac_err_assert = 0;
  25. EXPORT_SYMBOL_GPL(edac_err_assert);
  26. static atomic_t edac_subsys_valid = ATOMIC_INIT(0);
  27. /*
  28. * called to determine if there is an EDAC driver interested in
  29. * knowing an event (such as NMI) occurred
  30. */
  31. int edac_handler_set(void)
  32. {
  33. if (edac_op_state == EDAC_OPSTATE_POLL)
  34. return 0;
  35. return atomic_read(&edac_handlers);
  36. }
  37. EXPORT_SYMBOL_GPL(edac_handler_set);
  38. /*
  39. * handler for NMI type of interrupts to assert error
  40. */
  41. void edac_atomic_assert_error(void)
  42. {
  43. edac_err_assert++;
  44. }
  45. EXPORT_SYMBOL_GPL(edac_atomic_assert_error);
  46. /*
  47. * sysfs object: /sys/devices/system/edac
  48. * need to export to other files
  49. */
  50. struct bus_type edac_subsys = {
  51. .name = "edac",
  52. .dev_name = "edac",
  53. };
  54. EXPORT_SYMBOL_GPL(edac_subsys);
  55. /* return pointer to the 'edac' node in sysfs */
  56. struct bus_type *edac_get_sysfs_subsys(void)
  57. {
  58. int err = 0;
  59. if (atomic_read(&edac_subsys_valid))
  60. goto out;
  61. /* create the /sys/devices/system/edac directory */
  62. err = subsys_system_register(&edac_subsys, NULL);
  63. if (err) {
  64. printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
  65. return NULL;
  66. }
  67. out:
  68. atomic_inc(&edac_subsys_valid);
  69. return &edac_subsys;
  70. }
  71. EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys);
  72. void edac_put_sysfs_subsys(void)
  73. {
  74. /* last user unregisters it */
  75. if (atomic_dec_and_test(&edac_subsys_valid))
  76. bus_unregister(&edac_subsys);
  77. }
  78. EXPORT_SYMBOL_GPL(edac_put_sysfs_subsys);