edac_stub.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 <asm/atomic.h>
  18. #include <asm/edac.h>
  19. int edac_op_state = EDAC_OPSTATE_INVAL;
  20. EXPORT_SYMBOL_GPL(edac_op_state);
  21. atomic_t edac_handlers = ATOMIC_INIT(0);
  22. EXPORT_SYMBOL_GPL(edac_handlers);
  23. int edac_err_assert = 0;
  24. EXPORT_SYMBOL_GPL(edac_err_assert);
  25. static atomic_t edac_class_valid = ATOMIC_INIT(0);
  26. /*
  27. * called to determine if there is an EDAC driver interested in
  28. * knowing an event (such as NMI) occurred
  29. */
  30. int edac_handler_set(void)
  31. {
  32. if (edac_op_state == EDAC_OPSTATE_POLL)
  33. return 0;
  34. return atomic_read(&edac_handlers);
  35. }
  36. EXPORT_SYMBOL_GPL(edac_handler_set);
  37. /*
  38. * handler for NMI type of interrupts to assert error
  39. */
  40. void edac_atomic_assert_error(void)
  41. {
  42. edac_err_assert++;
  43. }
  44. EXPORT_SYMBOL_GPL(edac_atomic_assert_error);
  45. /*
  46. * sysfs object: /sys/devices/system/edac
  47. * need to export to other files
  48. */
  49. struct sysdev_class edac_class = {
  50. .name = "edac",
  51. };
  52. EXPORT_SYMBOL_GPL(edac_class);
  53. /* return pointer to the 'edac' node in sysfs */
  54. struct sysdev_class *edac_get_sysfs_class(void)
  55. {
  56. int err = 0;
  57. if (atomic_read(&edac_class_valid))
  58. goto out;
  59. /* create the /sys/devices/system/edac directory */
  60. err = sysdev_class_register(&edac_class);
  61. if (err) {
  62. printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
  63. return NULL;
  64. }
  65. out:
  66. atomic_inc(&edac_class_valid);
  67. return &edac_class;
  68. }
  69. EXPORT_SYMBOL_GPL(edac_get_sysfs_class);
  70. void edac_put_sysfs_class(void)
  71. {
  72. /* last user unregisters it */
  73. if (atomic_dec_and_test(&edac_class_valid))
  74. sysdev_class_unregister(&edac_class);
  75. }
  76. EXPORT_SYMBOL_GPL(edac_put_sysfs_class);