Skip to content

Commit 441fa10

Browse files
khfengrafaeljw
authored andcommitted
ACPI: APEI: GHES: Add devm_ghes_register_vendor_record_notifier()
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>
1 parent 591cd65 commit 441fa10

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

drivers/acpi/apei/ghes.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,24 @@ void ghes_unregister_vendor_record_notifier(struct notifier_block *nb)
689689
}
690690
EXPORT_SYMBOL_GPL(ghes_unregister_vendor_record_notifier);
691691

692+
static void ghes_vendor_record_notifier_destroy(void *nb)
693+
{
694+
ghes_unregister_vendor_record_notifier(nb);
695+
}
696+
697+
int devm_ghes_register_vendor_record_notifier(struct device *dev,
698+
struct notifier_block *nb)
699+
{
700+
int ret;
701+
702+
ret = ghes_register_vendor_record_notifier(nb);
703+
if (ret)
704+
return ret;
705+
706+
return devm_add_action_or_reset(dev, ghes_vendor_record_notifier_destroy, nb);
707+
}
708+
EXPORT_SYMBOL_GPL(devm_ghes_register_vendor_record_notifier);
709+
692710
static void ghes_vendor_record_work_func(struct work_struct *work)
693711
{
694712
struct ghes_vendor_record_entry *entry;

include/acpi/ghes.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ int ghes_register_vendor_record_notifier(struct notifier_block *nb);
7171
*/
7272
void ghes_unregister_vendor_record_notifier(struct notifier_block *nb);
7373

74+
/**
75+
* devm_ghes_register_vendor_record_notifier - device-managed vendor
76+
* record notifier registration.
77+
* @dev: device that owns the notifier lifetime
78+
* @nb: pointer to the notifier_block structure of the vendor record handler
79+
*
80+
* Return: 0 on success, negative errno on failure.
81+
*/
82+
int devm_ghes_register_vendor_record_notifier(struct device *dev,
83+
struct notifier_block *nb);
84+
7485
struct list_head *ghes_get_devices(void);
7586

7687
void ghes_estatus_pool_region_free(unsigned long addr, u32 size);

0 commit comments

Comments
 (0)