linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 7/7] power: supply: cros_pchg: use devm_blocking_notifier_chain_register()
       [not found] <20261113104459.35839-1-farbere@amazon.com>
@ 2026-11-13 10:44 ` Eliav Farber
  0 siblings, 0 replies; only message in thread
From: Eliav Farber @ 2026-11-13 10:44 UTC (permalink / raw)
  To: Rafael J. Wysocki, Dmitry Torokhov, Laurent Pinchart,
	Hans de Goede, Ilpo Järvinen, Armin Wolf, Sebastian Reichel,
	Andrew Morton
  Cc: Eliav Farber, linux-pm, linux-kernel, Pengpeng Hou

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.

Signed-off-by: Eliav Farber <farbere@amazon.com>
---
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(-)

diff --git a/drivers/power/supply/cros_peripheral_charger.c b/drivers/power/supply/cros_peripheral_charger.c
index fdfa510f0f2d..d171bd56f479 100644
--- a/drivers/power/supply/cros_peripheral_charger.c
+++ b/drivers/power/supply/cros_peripheral_charger.c
@@ -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
-- 
2.47.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-13 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261113104459.35839-1-farbere@amazon.com>
2026-11-13 10:44 ` [PATCH v6 7/7] power: supply: cros_pchg: use devm_blocking_notifier_chain_register() Eliav Farber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).