Skip to contentSkip to conversation

platform/x86: uniwill-wmi: use devm_blocking_notifier_chain_register()

PATCH Applied Eliav Farber 3 participants 8 messages Nov 13

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v6 5/7 platform/x86: uniwill-wmi: use devm_blocking_notifier_chain_register()

Replace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the devm_uniwill_wmi_unregister_notifier() callback.

---
Changes in v6:
- Rebased onto v7.4-rc1. No functional change since v5.
- Armin Wolf's Reviewed-by retained; the code is unchanged since v4, when it was given.

devm_uniwill_wmi_register_notifier() is kept rather than having uniwill-acpi.c call devm_blocking_notifier_chain_register() directly, because uniwill_wmi_chain_head is static to uniwill-wmi.c and dropping the wrapper would mean exposing it in uniwill-wmi.h. Discussed with Uwe Kleine-Koenig on v4.

 drivers/platform/x86/uniwill/uniwill-wmi.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/platform/x86/uniwill/uniwill-wmi.c +3 -14
index afcbfa4f7552..2ffa29a829ee 100644
@@ -26,22 +26,11 @@
 
 static BLOCKING_NOTIFIER_HEAD(uniwill_wmi_chain_head);
 
-static void devm_uniwill_wmi_unregister_notifier(void *data)
-{
-	struct notifier_block *nb = data;
-
-	blocking_notifier_chain_unregister(&uniwill_wmi_chain_head, nb);
-}
-
 int devm_uniwill_wmi_register_notifier(struct device *dev, struct notifier_block *nb)
 {
-	int ret;
-
-	ret = blocking_notifier_chain_register(&uniwill_wmi_chain_head, nb);
-	if (ret < 0)
-		return ret;
-
-	return devm_add_action_or_reset(dev, devm_uniwill_wmi_unregister_notifier, nb);
+	return devm_blocking_notifier_chain_register(dev,
+						     &uniwill_wmi_chain_head,
+						     nb);
 }
 
 static void uniwill_wmi_notify(struct wmi_device *wdev, union acpi_object *obj)
Signature · 1 line
2.47.3
#1 lore raw

PATCH v6 6/7 reboot: use devm_blocking_notifier_chain_register()

Replace the manual devres_alloc() + register_reboot_notifier() pattern with a single call to devm_blocking_notifier_chain_register(), removing the devm_unregister_reboot_notifier() callback.

The removed callback wrapped unregister_reboot_notifier() in WARN_ON(). The generic helper ignores the unregister return value, so that warning is gone. It could only fire if a caller had already unregistered the notifier itself, which no in-tree user does.

---
Changes in v6:
- Rebased onto v7.4-rc1.
- Commit message: record that the removed callback's WARN_ON() on a failed unregister goes away, because devm_blocking_notifier_chain_register() ignores the unregister return value. No change to the code.

Changes in v3:
- Fix commit message to accurately describe the old code as using devres_alloc() + register_reboot_notifier() (Sashiko)

 kernel/reboot.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)
kernel/reboot.c +2 -22
index 9a84401adde5..2fb8700c726d 100644
@@ -146,30 +146,10 @@ int unregister_reboot_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL(unregister_reboot_notifier);
 
-static void devm_unregister_reboot_notifier(struct device *dev, void *res)
-{
-	WARN_ON(unregister_reboot_notifier(*(struct notifier_block **)res));
-}
-
 int devm_register_reboot_notifier(struct device *dev, struct notifier_block *nb)
 {
-	struct notifier_block **rcnb;
-	int ret;
-
-	rcnb = devres_alloc(devm_unregister_reboot_notifier,
-			    sizeof(*rcnb), GFP_KERNEL);
-	if (!rcnb)
-		return -ENOMEM;
-
-	ret = register_reboot_notifier(nb);
-	if (!ret) {
-		*rcnb = nb;
-		devres_add(dev, rcnb);
-	} else {
-		devres_free(rcnb);
-	}
-
-	return ret;
+	return devm_blocking_notifier_chain_register(dev,
+						     &reboot_notifier_list, nb);
 }
 EXPORT_SYMBOL(devm_register_reboot_notifier);
 
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH v6 6/7] reboot: use devm_blocking_notifier_chain_register()

This patch is not in the series thread. My mail server refused the second half of the series with a submission rate limit, and the resend went out unthreaded, so 5/7, 6/7 and 7/7 are rooted at 5/7 instead of under the cover letter.

The cover letter and patches 1/7 to 4/7 are here:

0/7 https://lore.kernel.org/all/[email protected]/

All seven patches were delivered, so I am not resending them. Sorry for the split thread.

--
Thanks, Eliav

Reviewed-by on v6 6/7
#3 lore raw

Re: [PATCH v6 6/7] reboot: use devm_blocking_notifier_chain_register()

In reply to Eliav Farber
Quoted 8 lines · Eliav Farber

Replace the manual devres_alloc() + register_reboot_notifier() pattern with a single call to devm_blocking_notifier_chain_register(), removing the devm_unregister_reboot_notifier() callback.

The removed callback wrapped unregister_reboot_notifier() in WARN_ON(). The generic helper ignores the unregister return value, so that warning is gone. It could only fire if a caller had already unregistered the notifier itself, which no in-tree user does.

Good. Cleanup well needed

Quoted 52 lines

---
Changes in v6:
- Rebased onto v7.4-rc1.
- Commit message: record that the removed callback's WARN_ON() on a failed unregister goes away, because devm_blocking_notifier_chain_register() ignores the unregister return value. No change to the code.

Changes in v3:
- Fix commit message to accurately describe the old code as using devres_alloc() + register_reboot_notifier() (Sashiko)

kernel/reboot.c | 24 ++----------------------

1 file changed, 2 insertions(+), 22 deletions(-)
kernel/reboot.c +0 -5
index 9a84401adde5..2fb8700c726d 100644
@@ -146,30 +146,10 @@ int unregister_reboot_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL(unregister_reboot_notifier);
 
-static void devm_unregister_reboot_notifier(struct device *dev, void *res)
-{
-	WARN_ON(unregister_reboot_notifier(*(struct notifier_block **)res));
-}
-

int devm_register_reboot_notifier(struct device *dev, struct notifier_block *nb)
{

kernel/reboot.c +2 -17
-	struct notifier_block **rcnb;
-	int ret;
-
-	rcnb = devres_alloc(devm_unregister_reboot_notifier,
-			    sizeof(*rcnb), GFP_KERNEL);
-	if (!rcnb)
-		return -ENOMEM;
-
-	ret = register_reboot_notifier(nb);
-	if (!ret) {
-		*rcnb = nb;
-		devres_add(dev, rcnb);
-	} else {
-		devres_free(rcnb);
-	}
-
-	return ret;
+	return devm_blocking_notifier_chain_register(dev,
+						     &reboot_notifier_list, nb);
Quoted 4 lines

}
EXPORT_SYMBOL(devm_register_reboot_notifier);

--- Thanks!

#4 lore raw

PATCH v6 7/7 power: supply: cros_pchg: use devm_blocking_notifier_chain_register()

In reply to Eliav Farber

Replace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the cros_pchg_unregister_notifier() callback.

---
Changes in v6:
- New patch. cros_peripheral_charger.c grew the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern in 631adfa03595 ("power: supply: cros_pchg: unregister EC notifier"), which reached mainline in v7.3-rc1 on 2026-08-21, five days after v5 was posted, so earlier revisions could not have covered it.

The conversion keeps the existing dev_err_probe() message, and removes one asymmetry: the old code registered on ec_dev->ec_dev->event_notifier but unregistered on charger->ec_device->event_notifier. Those are the same chain - charger->ec_device is assigned from ec_dev->ec_dev earlier in probe - and there is now a single reference to it.

 drivers/power/supply/cros_peripheral_charger.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/power/supply/cros_peripheral_charger.c +4 -12
index fdfa510f0f2d..d171bd56f479 100644
@@ -258,14 +258,6 @@ static int cros_ec_notify(struct notifier_block *nb,
 	return cros_pchg_event(charger);
 }
 
-static void cros_pchg_unregister_notifier(void *data)
-{
-	struct charger_data *charger = data;
-
-	blocking_notifier_chain_unregister(&charger->ec_device->event_notifier,
-					   &charger->notifier);
-}
-
 static int cros_pchg_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -350,13 +342,13 @@ static int cros_pchg_probe(struct platform_device *pdev)
 
 	nb = &charger->notifier;
 	nb->notifier_call = cros_ec_notify;
-	ret = blocking_notifier_chain_register(&ec_dev->ec_dev->event_notifier,
-					       nb);
+	ret = devm_blocking_notifier_chain_register(dev,
+						    &ec_dev->ec_dev->event_notifier,
+						    nb);
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "Failed to register notifier\n");
 
-	return devm_add_action_or_reset(dev, cros_pchg_unregister_notifier,
-					charger);
+	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.3
#5 lore raw

Re: [PATCH v6 7/7] power: supply: cros_pchg: use devm_blocking_notifier_chain_register()

This patch is not in the series thread. My mail server refused the second half of the series with a submission rate limit, and the resend went out unthreaded, so 5/7, 6/7 and 7/7 are rooted at 5/7 instead of under the cover letter.

The cover letter and patches 1/7 to 4/7 are here:

0/7 https://lore.kernel.org/all/[email protected]/

All seven patches were delivered, so I am not resending them. Sorry for the split thread.

--
Thanks, Eliav

#6 lore raw
In reply to Eliav Farber

This patch is not in the series thread. My mail server refused the second half of the series with a submission rate limit, and the resend went out unthreaded, so 5/7, 6/7 and 7/7 are rooted at 5/7 instead of under the cover letter.

The cover letter and patches 1/7 to 4/7 are here:

0/7 https://lore.kernel.org/all/[email protected]/

All seven patches were delivered, so I am not resending them. Sorry for the split thread.

--
Thanks, Eliav

maintainer
#7 lore raw
In reply to Eliav Farber
Quoted 4 lines · Eliav Farber

Replace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the devm_uniwill_wmi_unregister_notifier() callback.

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[5/7] platform/x86: uniwill-wmi: use devm_blocking_notifier_chain_register()

      commit: 4a53f320115d5f7c21c8fd899b362b5719a51946

[6/7] reboot: use devm_blocking_notifier_chain_register()
(no commit info)
[7/7] power: supply: cros_pchg: use devm_blocking_notifier_chain_register()
(no commit info)

--
i.