hed.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * ACPI Hardware Error Device (PNP0C33) Driver
  4. *
  5. * Copyright (C) 2010, Intel Corp.
  6. * Author: Huang Ying <ying.huang@intel.com>
  7. *
  8. * ACPI Hardware Error Device is used to report some hardware errors
  9. * notified via SCI, mainly the corrected errors.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/init.h>
  14. #include <linux/acpi.h>
  15. #include <acpi/hed.h>
  16. static const struct acpi_device_id acpi_hed_ids[] = {
  17. {"PNP0C33", 0},
  18. {"", 0},
  19. };
  20. MODULE_DEVICE_TABLE(acpi, acpi_hed_ids);
  21. static acpi_handle hed_handle;
  22. static BLOCKING_NOTIFIER_HEAD(acpi_hed_notify_list);
  23. int register_acpi_hed_notifier(struct notifier_block *nb)
  24. {
  25. return blocking_notifier_chain_register(&acpi_hed_notify_list, nb);
  26. }
  27. EXPORT_SYMBOL_GPL(register_acpi_hed_notifier);
  28. void unregister_acpi_hed_notifier(struct notifier_block *nb)
  29. {
  30. blocking_notifier_chain_unregister(&acpi_hed_notify_list, nb);
  31. }
  32. EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier);
  33. /*
  34. * SCI to report hardware error is forwarded to the listeners of HED,
  35. * it is used by HEST Generic Hardware Error Source with notify type
  36. * SCI.
  37. */
  38. static void acpi_hed_notify(struct acpi_device *device, u32 event)
  39. {
  40. blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL);
  41. }
  42. static int acpi_hed_add(struct acpi_device *device)
  43. {
  44. /* Only one hardware error device */
  45. if (hed_handle)
  46. return -EINVAL;
  47. hed_handle = device->handle;
  48. return 0;
  49. }
  50. static int acpi_hed_remove(struct acpi_device *device)
  51. {
  52. hed_handle = NULL;
  53. return 0;
  54. }
  55. static struct acpi_driver acpi_hed_driver = {
  56. .name = "hardware_error_device",
  57. .class = "hardware_error",
  58. .ids = acpi_hed_ids,
  59. .ops = {
  60. .add = acpi_hed_add,
  61. .remove = acpi_hed_remove,
  62. .notify = acpi_hed_notify,
  63. },
  64. };
  65. module_acpi_driver(acpi_hed_driver);
  66. ACPI_MODULE_NAME("hed");
  67. MODULE_AUTHOR("Huang Ying");
  68. MODULE_DESCRIPTION("ACPI Hardware Error Device Driver");
  69. MODULE_LICENSE("GPL");