]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: APEI: GHES: Add devm_ghes_register_vendor_record_notifier()
authorKai-Heng Feng <kaihengf@nvidia.com>
Mon, 30 Mar 2026 09:41:55 +0000 (17:41 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 6 Apr 2026 14:48:58 +0000 (16:48 +0200)
Add a device-managed wrapper around ghes_register_vendor_record_notifier()
so drivers can avoid manual cleanup on device removal or probe failure.

Signed-off-by: Kai-Heng Feng <kaihengf@nvidia.com>
Reviewed-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Shiju Jose <shiju.jose@huawei.com>
Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>
Link: https://patch.msgid.link/20260330094203.38022-2-kaihengf@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/apei/ghes.c
include/acpi/ghes.h

index 8acd2742bb27d528925b73500dae64e2b8e06fe3..3236a3ce79d6bd1f558df44f5f8c856466744853 100644 (file)
@@ -689,6 +689,24 @@ void ghes_unregister_vendor_record_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(ghes_unregister_vendor_record_notifier);
 
+static void ghes_vendor_record_notifier_destroy(void *nb)
+{
+       ghes_unregister_vendor_record_notifier(nb);
+}
+
+int devm_ghes_register_vendor_record_notifier(struct device *dev,
+                                             struct notifier_block *nb)
+{
+       int ret;
+
+       ret = ghes_register_vendor_record_notifier(nb);
+       if (ret)
+               return ret;
+
+       return devm_add_action_or_reset(dev, ghes_vendor_record_notifier_destroy, nb);
+}
+EXPORT_SYMBOL_GPL(devm_ghes_register_vendor_record_notifier);
+
 static void ghes_vendor_record_work_func(struct work_struct *work)
 {
        struct ghes_vendor_record_entry *entry;
index 7bea522c065753d2233c93487242b6743b3de0e7..8d7e5caef3f18a3d7adf6d28a15fdbcaef82a8e8 100644 (file)
@@ -71,6 +71,17 @@ int ghes_register_vendor_record_notifier(struct notifier_block *nb);
  */
 void ghes_unregister_vendor_record_notifier(struct notifier_block *nb);
 
+/**
+ * devm_ghes_register_vendor_record_notifier - device-managed vendor
+ * record notifier registration.
+ * @dev: device that owns the notifier lifetime
+ * @nb: pointer to the notifier_block structure of the vendor record handler
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int devm_ghes_register_vendor_record_notifier(struct device *dev,
+                                             struct notifier_block *nb);
+
 struct list_head *ghes_get_devices(void);
 
 void ghes_estatus_pool_region_free(unsigned long addr, u32 size);