Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * ACPI Hardware Error Device (PNP0C33) Driver
0004  *
0005  * Copyright (C) 2010, Intel Corp.
0006  *  Author: Huang Ying <ying.huang@intel.com>
0007  *
0008  * ACPI Hardware Error Device is used to report some hardware errors
0009  * notified via SCI, mainly the corrected errors.
0010  */
0011 
0012 #include <linux/kernel.h>
0013 #include <linux/module.h>
0014 #include <linux/init.h>
0015 #include <linux/acpi.h>
0016 #include <acpi/hed.h>
0017 
0018 static const struct acpi_device_id acpi_hed_ids[] = {
0019     {"PNP0C33", 0},
0020     {"", 0},
0021 };
0022 MODULE_DEVICE_TABLE(acpi, acpi_hed_ids);
0023 
0024 static acpi_handle hed_handle;
0025 
0026 static BLOCKING_NOTIFIER_HEAD(acpi_hed_notify_list);
0027 
0028 int register_acpi_hed_notifier(struct notifier_block *nb)
0029 {
0030     return blocking_notifier_chain_register(&acpi_hed_notify_list, nb);
0031 }
0032 EXPORT_SYMBOL_GPL(register_acpi_hed_notifier);
0033 
0034 void unregister_acpi_hed_notifier(struct notifier_block *nb)
0035 {
0036     blocking_notifier_chain_unregister(&acpi_hed_notify_list, nb);
0037 }
0038 EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier);
0039 
0040 /*
0041  * SCI to report hardware error is forwarded to the listeners of HED,
0042  * it is used by HEST Generic Hardware Error Source with notify type
0043  * SCI.
0044  */
0045 static void acpi_hed_notify(struct acpi_device *device, u32 event)
0046 {
0047     blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL);
0048 }
0049 
0050 static int acpi_hed_add(struct acpi_device *device)
0051 {
0052     /* Only one hardware error device */
0053     if (hed_handle)
0054         return -EINVAL;
0055     hed_handle = device->handle;
0056     return 0;
0057 }
0058 
0059 static int acpi_hed_remove(struct acpi_device *device)
0060 {
0061     hed_handle = NULL;
0062     return 0;
0063 }
0064 
0065 static struct acpi_driver acpi_hed_driver = {
0066     .name = "hardware_error_device",
0067     .class = "hardware_error",
0068     .ids = acpi_hed_ids,
0069     .ops = {
0070         .add = acpi_hed_add,
0071         .remove = acpi_hed_remove,
0072         .notify = acpi_hed_notify,
0073     },
0074 };
0075 module_acpi_driver(acpi_hed_driver);
0076 
0077 MODULE_AUTHOR("Huang Ying");
0078 MODULE_DESCRIPTION("ACPI Hardware Error Device Driver");
0079 MODULE_LICENSE("GPL");