notifier: add device-managed registration APIs and convert drivers
v5 cover notifier: add device-managed registration APIs and convert drivers
Many drivers repeat the same boilerplate when registering notifiers with device lifetime:
1. Register the notifier with *_notifier_chain_register()
2. Check for error
3. Register a devm action to unregister on teardown
4. Implement a per-driver static unregister callback
This series adds devm_atomic_notifier_chain_register() and devm_blocking_notifier_chain_register() that automatically unregister the notifier when the device is unbound, then converts 11 drivers to use them.
Each conversion eliminates a per-driver unregister callback and the associated devm_add_action_or_reset() call, reducing code by ~15 lines per driver.
The implementation follows the established devres pattern used by other device-managed kernel APIs.
Changes in v5:
- Patch 1: rename notifier_block parameter from 'n' to 'nb' to match the devres struct field name (Uwe Kleine-König)
- Patch 2: remove extra blank line left after deleting the unregister callback (Uwe Kleine-König)
Changes in v4:
- Patch 8: split the removal of unused ghes_register_vendor_record_notifier() and ghes_unregister_vendor_record_notifier() into a separate preceding patch (Andy Shevchenko)
Changes in v3:
- Patch 1: drop devm_raw_notifier_chain_register() since raw notifiers require caller-provided locking which is incompatible with the devres teardown callback (Sashiko)
- Patch 12: fix commit message to accurately describe the old code as using devres_alloc() + register_reboot_notifier() (Sashiko)
Changes in v2:
- Patch 1: drop 'extern' from new function prototypes (Bart Van Assche)
- Patch 1: fix kerneldoc to use 'Return:' format (Bart Van Assche)
- Patch 1: use <linux/device/devres.h> instead of <linux/device.h> (Andy Shevchenko)
- Patch 8: also remove unused ghes_register_vendor_record_notifier() and ghes_unregister_vendor_record_notifier() along with their exports and ghes.h declarations (Jonathan Cameron)
Eliav Farber (13):
notifier: add device-managed registration APIs
pwm: iqs620a: use devm_blocking_notifier_chain_register()
iio: light: iqs621-als: use devm_blocking_notifier_chain_register()
iio: position: iqs624: use devm_blocking_notifier_chain_register()
gpio: adp5585: use devm_blocking_notifier_chain_register() platform/x86: bitland-mifs-wmi: use
devm_blocking_notifier_chain_register()
Input: adp5585: use devm_blocking_notifier_chain_register()
ACPI: APEI: GHES: remove unused
ghes_{,un}register_vendor_record_notifier()
ACPI: APEI: GHES: use devm_blocking_notifier_chain_register() platform/x86: uniwill-wmi: use devm_blocking_notifier_chain_register()
gpio: eic-sprd: use devm_atomic_notifier_chain_register()
gpio: gpiolib-kunit: use devm_blocking_notifier_chain_register()
reboot: use devm_blocking_notifier_chain_register()
drivers/acpi/apei/ghes.c | 27 +----- drivers/gpio/gpio-adp5585.c | 20 +--- drivers/gpio/gpio-eic-sprd.c | 17 +--- drivers/gpio/gpiolib-kunit.c | 14 +-- drivers/iio/light/iqs621-als.c | 24 +---- drivers/iio/position/iqs624-pos.c | 24 +---- drivers/input/keyboard/adp5585-keys.c | 18 +--- drivers/platform/x86/bitland-mifs-wmi.c | 17 +--- drivers/platform/x86/uniwill/uniwill-wmi.c | 17 +--- drivers/pwm/pwm-iqs620a.c | 23 +---- include/acpi/ghes.h | 16 ---- include/linux/notifier.h | 7 ++ kernel/notifier.c | 103 +++++++++++++++++++++ kernel/reboot.c | 24 +---- 14 files changed, 140 insertions(+), 211 deletions(-)
Signature · 1 line
2.47.3
PATCH v5 1/13 notifier: add device-managed registration APIs
Add devm_atomic_notifier_chain_register() and devm_blocking_notifier_chain_register() that automatically unregister the notifier when the device is unbound.
Many drivers repeat the same boilerplate pattern:
1. Register the notifier with *_notifier_chain_register()
2. Check for error
3. Register a devm action to unregister on teardown
4. Implement a per-driver static unregister callback
With the new devm_*_notifier_chain_register() APIs, this reduces to a single call with one error path, eliminating per-driver unregister callbacks entirely.
The implementation follows the established devres pattern used by other device-managed kernel APIs.
A devm variant for raw notifier chains is intentionally not included because raw notifiers require the caller to provide all locking. The devres teardown callback has no way to acquire the caller's lock, and devres_alloc() with GFP_KERNEL cannot be used if the caller's lock is a spinlock.
---
Changes in v5:
- Rename notifier_block parameter from 'n' to 'nb' to match the devres struct field name (Uwe Kleine-König)
Changes in v3:
- Drop devm_raw_notifier_chain_register() since raw notifiers require caller-provided locking which is incompatible with the devres teardown callback (Sashiko)
Changes in v2:
- Drop 'extern' from new function prototypes (Bart Van Assche)
- Fix kerneldoc to use 'Return:' format (Bart Van Assche)
- Use <linux/device/devres.h> instead of <linux/device.h> (Andy Shevchenko)
include/linux/notifier.h | 7 +++ kernel/notifier.c | 103 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)
include/linux/notifier.h +7 -0
@@ -46,6 +46,7 @@* often but notifier_blocks will seldom be removed. */ +struct device ;struct notifier_block ; typedef int (*notifier_fn_t)(struct notifier_block *nb,
@@ -145,8 +146,14 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);extern int atomic_notifier_chain_register (struct atomic_notifier_head *nh,struct notifier_block *nb); +int devm_atomic_notifier_chain_register (struct device *dev, +struct atomic_notifier_head *nh, +struct notifier_block *nb);extern int blocking_notifier_chain_register (struct blocking_notifier_head *nh,struct notifier_block *nb); +int devm_blocking_notifier_chain_register (struct device *dev, +struct blocking_notifier_head *nh, +struct notifier_block *nb);extern int raw_notifier_chain_register (struct raw_notifier_head *nh,struct notifier_block *nb); extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
kernel/notifier.c +103 -0
119 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v5 2/13 pwm: iqs620a: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the iqs620_pwm_notifier_unregister() callback.
---
Changes in v5:
- Remove extra blank line left after deleting the unregister callback (Uwe Kleine-König)
drivers/pwm/pwm-iqs620a.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-)
drivers/pwm/pwm-iqs620a.c +3 -20
@@ -173,18 +173,6 @@ static const struct pwm_ops iqs620_pwm_ops = { .get_state = iqs620_pwm_get_state, }; -static void iqs620_pwm_notifier_unregister (void *context) -{ -struct iqs620_pwm_private *iqs620_pwm = context; -int ret; - - ret =blocking_notifier_chain_unregister (&iqs620_pwm->iqs62x->nh, - &iqs620_pwm->notifier); -if (ret) -dev_err (iqs620_pwm->dev, -"Failed to unregister notifier: %d\n" , ret); -} -static int iqs620_pwm_probe (struct platform_device *pdev) {struct iqs62x_core *iqs62x =dev_get_drvdata (pdev->dev.parent);
@@ -218,19 +206,14 @@ static int iqs620_pwm_probe(struct platform_device *pdev)mutex_init (&iqs620_pwm->lock); iqs620_pwm->notifier.notifier_call = iqs620_pwm_notifier; - ret =blocking_notifier_chain_register (&iqs620_pwm->iqs62x->nh, - &iqs620_pwm->notifier); + ret =devm_blocking_notifier_chain_register (&pdev->dev, + &iqs620_pwm->iqs62x->nh, + &iqs620_pwm->notifier);if (ret) {dev_err (&pdev->dev,"Failed to register notifier: %d\n" , ret);return ret; } - ret =devm_add_action_or_reset (&pdev->dev, - iqs620_pwm_notifier_unregister, - iqs620_pwm); -if (ret) -return ret; - ret =devm_pwmchip_add (&pdev->dev, chip);if (ret)dev_err (&pdev->dev,"Failed to add device: %d\n" , ret);
Signature · 1 line
2.47.3
PATCH v5 4/13 iio: position: iqs624: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the iqs624_pos_notifier_unregister() callback.
--- drivers/iio/position/iqs624-pos.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
drivers/iio/position/iqs624-pos.c +3 -21
@@ -96,19 +96,6 @@ static int iqs624_pos_notifier(struct notifier_block *notifier,return ret; } -static void iqs624_pos_notifier_unregister (void *context) -{ -struct iqs624_pos_private *iqs624_pos = context; -struct iio_dev *indio_dev = iqs624_pos->indio_dev; -int ret; - - ret =blocking_notifier_chain_unregister (&iqs624_pos->iqs62x->nh, - &iqs624_pos->notifier); -if (ret) -dev_err (indio_dev->dev.parent, -"Failed to unregister notifier: %d\n" , ret); -} -static int iqs624_pos_angle_get (struct iqs62x_core *iqs62x,unsigned int *val) {int ret;
@@ -255,19 +242,14 @@ static int iqs624_pos_probe(struct platform_device *pdev)mutex_init (&iqs624_pos->lock); iqs624_pos->notifier.notifier_call = iqs624_pos_notifier; - ret =blocking_notifier_chain_register (&iqs624_pos->iqs62x->nh, - &iqs624_pos->notifier); + ret =devm_blocking_notifier_chain_register (&pdev->dev, + &iqs624_pos->iqs62x->nh, + &iqs624_pos->notifier);if (ret) {dev_err (&pdev->dev,"Failed to register notifier: %d\n" , ret);return ret; } - ret =devm_add_action_or_reset (&pdev->dev, - iqs624_pos_notifier_unregister, - iqs624_pos); -if (ret) -return ret; -return devm_iio_device_register (&pdev->dev, indio_dev); }
Signature · 1 line
2.47.3
PATCH v5 3/13 iio: light: iqs621-als: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the iqs621_als_notifier_unregister() callback.
--- drivers/iio/light/iqs621-als.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
drivers/iio/light/iqs621-als.c +3 -21
@@ -179,19 +179,6 @@ static int iqs621_als_notifier(struct notifier_block *notifier,return NOTIFY_OK ; } -static void iqs621_als_notifier_unregister (void *context) -{ -struct iqs621_als_private *iqs621_als = context; -struct iio_dev *indio_dev = iqs621_als->indio_dev; -int ret; - - ret =blocking_notifier_chain_unregister (&iqs621_als->iqs62x->nh, - &iqs621_als->notifier); -if (ret) -dev_err (indio_dev->dev.parent, -"Failed to unregister notifier: %d\n" , ret); -} -static int iqs621_als_read_raw (struct iio_dev *indio_dev,struct iio_chan_spec const *chan,int *val,int *val2,long mask)
@@ -563,19 +550,14 @@ static int iqs621_als_probe(struct platform_device *pdev)mutex_init (&iqs621_als->lock); iqs621_als->notifier.notifier_call = iqs621_als_notifier; - ret =blocking_notifier_chain_register (&iqs621_als->iqs62x->nh, - &iqs621_als->notifier); + ret =devm_blocking_notifier_chain_register (&pdev->dev, + &iqs621_als->iqs62x->nh, + &iqs621_als->notifier);if (ret) {dev_err (&pdev->dev,"Failed to register notifier: %d\n" , ret);return ret; } - ret =devm_add_action_or_reset (&pdev->dev, - iqs621_als_notifier_unregister, - iqs621_als); -if (ret) -return ret; -return devm_iio_device_register (&pdev->dev, indio_dev); }
Signature · 1 line
2.47.3
PATCH v5 5/13 gpio: adp5585: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the adp5585_gpio_unreg_notifier() callback.
--- drivers/gpio/gpio-adp5585.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/gpio/gpio-adp5585.c +3 -17
@@ -390,16 +390,6 @@ static const struct irq_chip adp5585_irq_chip = { GPIOCHIP_IRQ_RESOURCE_HELPERS, }; -static void adp5585_gpio_unreg_notifier (void *data) -{ -struct adp5585_gpio_dev *adp5585_gpio = data; -struct device *dev = adp5585_gpio->gpio_chip.parent; -struct adp5585_dev *adp5585 =dev_get_drvdata (dev->parent); - -blocking_notifier_chain_unregister (&adp5585->event_notifier, - &adp5585_gpio->nb); -} -static int adp5585_gpio_probe (struct platform_device *pdev) {struct adp5585_dev *adp5585 =dev_get_drvdata (pdev->dev.parent);
@@ -450,13 +440,9 @@ static int adp5585_gpio_probe(struct platform_device *pdev) girq->threaded = true; adp5585_gpio->nb.notifier_call = adp5585_gpio_key_event; - ret =blocking_notifier_chain_register (&adp5585->event_notifier, - &adp5585_gpio->nb); -if (ret) -return ret; - - ret =devm_add_action_or_reset (dev, adp5585_gpio_unreg_notifier, - adp5585_gpio); + ret =devm_blocking_notifier_chain_register (dev, + &adp5585->event_notifier, + &adp5585_gpio->nb);if (ret)return ret; }
Signature · 1 line
2.47.3
PATCH v5 6/13 platform/x86: bitland-mifs-wmi: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the bitland_notifier_unregister() callback.
--- drivers/platform/x86/bitland-mifs-wmi.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +3 -14
@@ -623,13 +623,6 @@ static const struct key_entry bitland_mifs_wmi_keymap[] = { { KE_END, 0 } }; -static void bitland_notifier_unregister (void *data) -{ -struct notifier_block *nb = data; - -blocking_notifier_chain_unregister (&bitland_notifier_list, nb); -} -static int bitland_notifier_callback (struct notifier_block *nb,unsigned long action,void *data) {
@@ -729,13 +722,9 @@ static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context)return ret; drv_data->notifier.notifier_call = bitland_notifier_callback; - ret =blocking_notifier_chain_register (&bitland_notifier_list, &drv_data->notifier); -if (ret) -return ret; - -return devm_add_action_or_reset (&wdev->dev, - bitland_notifier_unregister, - &drv_data->notifier); +return devm_blocking_notifier_chain_register (&wdev->dev, + &bitland_notifier_list, + &drv_data->notifier); } static void bitland_mifs_wmi_notify(struct wmi_device *wdev,
Signature · 1 line
2.47.3
PATCH v5 7/13 Input: adp5585: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the adp5585_keys_unreg_notifier() callback.
--- drivers/input/keyboard/adp5585-keys.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/input/keyboard/adp5585-keys.c +3 -15
@@ -254,15 +254,6 @@ static int adp5585_keys_ev_handle(struct notifier_block *nb, unsigned long key,return NOTIFY_STOP ; } -static void adp5585_keys_unreg_notifier (void *data) -{ -struct adp5585_kpad *kpad = data; -struct adp5585_dev *adp5585 =dev_get_drvdata (kpad->dev->parent); - -blocking_notifier_chain_unregister (&adp5585->event_notifier, - &kpad->nb); -} -static int adp5585_keys_probe (struct platform_device *pdev) {const struct platform_device_id *id =platform_get_device_id (pdev);
@@ -318,12 +309,9 @@ static int adp5585_keys_probe(struct platform_device *pdev)return error; kpad->nb.notifier_call = adp5585_keys_ev_handle; - error =blocking_notifier_chain_register (&adp5585->event_notifier, - &kpad->nb); -if (error) -return error; - - error =devm_add_action_or_reset (dev, adp5585_keys_unreg_notifier, kpad); + error =devm_blocking_notifier_chain_register (dev, + &adp5585->event_notifier, + &kpad->nb);if (error)return error;
Signature · 1 line
2.47.3
PATCH v5 8/13 ACPI: APEI: GHES: remove unused ghes_{,un}register_vendor_record_notifier()
In reply to Eliav FarberRemove ghes_register_vendor_record_notifier() and ghes_unregister_vendor_record_notifier() along with their EXPORT_SYMBOL_GPL()s and ghes.h declarations, since there are no remaining in-tree callers — all users go through devm_ghes_register_vendor_record_notifier() instead.
Inline the register/unregister calls directly into devm_ghes_register_vendor_record_notifier() and its destroy callback.
---
Changes in v4:
- Split from the devm conversion patch into its own commit (Andy Shevchenko)
Changes in v2:
- New patch: remove unused ghes_register_vendor_record_notifier() and ghes_unregister_vendor_record_notifier() along with their EXPORT_SYMBOL_GPL()s and ghes.h declarations, since there are no in-tree callers (Jonathan Cameron)
drivers/acpi/apei/ghes.c | 16 +++------------- include/acpi/ghes.h | 16 ---------------- 2 files changed, 3 insertions(+), 29 deletions(-)
drivers/acpi/apei/ghes.c +3 -13
@@ -677,29 +677,19 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)static BLOCKING_NOTIFIER_HEAD (vendor_record_notify_list); -int ghes_register_vendor_record_notifier (struct notifier_block *nb) +static void ghes_vendor_record_notifier_destroy (void *data) { -return blocking_notifier_chain_register (&vendor_record_notify_list, nb); -} -EXPORT_SYMBOL_GPL (ghes_register_vendor_record_notifier); +struct notifier_block *nb = data; -void ghes_unregister_vendor_record_notifier (struct notifier_block *nb) -{blocking_notifier_chain_unregister (&vendor_record_notify_list, 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); + ret =blocking_notifier_chain_register (&vendor_record_notify_list, nb);if (ret)return ret;
include/acpi/ghes.h +0 -16
@@ -55,22 +55,6 @@ enum { };#ifdef CONFIG_ACPI_APEI_GHES -/** -* ghes_register_vendor_record_notifier - register a notifier for vendor -* records that the kernel would otherwise ignore. -* @nb: pointer to the notifier_block structure of the event handler. -* -* return 0 : SUCCESS, non-zero : FAIL -*/ -int ghes_register_vendor_record_notifier (struct notifier_block *nb); - -/** -* ghes_unregister_vendor_record_notifier - unregister the previously -* registered vendor record notifier. -* @nb: pointer to the notifier_block structure of the vendor record handler. -*/ -void ghes_unregister_vendor_record_notifier (struct notifier_block *nb); -/** * devm_ghes_register_vendor_record_notifier - device-managed vendor * record notifier registration.
Signature · 1 line
2.47.3
PATCH v5 9/13 ACPI: APEI: GHES: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the ghes_vendor_record_notifier_destroy() callback.
---
Changes in v4:
- Split removal of unused code into a separate preceding patch (Andy Shevchenko)
drivers/acpi/apei/ghes.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/acpi/apei/ghes.c +3 -14
@@ -677,23 +677,12 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)static BLOCKING_NOTIFIER_HEAD (vendor_record_notify_list); -static void ghes_vendor_record_notifier_destroy (void *data) -{ -struct notifier_block *nb = data; - -blocking_notifier_chain_unregister (&vendor_record_notify_list, nb); -} -int devm_ghes_register_vendor_record_notifier (struct device *dev,struct notifier_block *nb) { -int ret; - - ret =blocking_notifier_chain_register (&vendor_record_notify_list, nb); -if (ret) -return ret; - -return devm_add_action_or_reset (dev, ghes_vendor_record_notifier_destroy, nb); +return devm_blocking_notifier_chain_register (dev, + &vendor_record_notify_list, + nb); }EXPORT_SYMBOL_GPL (devm_ghes_register_vendor_record_notifier);
Signature · 1 line
2.47.3
PATCH v5 10/13 platform/x86: uniwill-wmi: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace 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.
--- drivers/platform/x86/uniwill/uniwill-wmi.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/platform/x86/uniwill/uniwill-wmi.c +3 -14
@@ -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
PATCH v5 11/13 gpio: eic-sprd: use devm_atomic_notifier_chain_register()
In reply to Eliav FarberReplace the atomic_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_atomic_notifier_chain_register(), removing the sprd_eic_unregister_notifier() callback.
--- drivers/gpio/gpio-eic-sprd.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/gpio/gpio-eic-sprd.c +2 -15
@@ -601,13 +601,6 @@ static const struct irq_chip sprd_eic_irq = { GPIOCHIP_IRQ_RESOURCE_HELPERS, }; -static void sprd_eic_unregister_notifier (void *data) -{ -struct notifier_block *nb = data; - -atomic_notifier_chain_unregister (&sprd_eic_irq_notifier, nb); -} -static int sprd_eic_probe (struct platform_device *pdev) {const struct sprd_eic_variant_data *pdata;
@@ -690,14 +683,8 @@ static int sprd_eic_probe(struct platform_device *pdev) } sprd_eic->irq_nb.notifier_call = sprd_eic_irq_notify; - ret =atomic_notifier_chain_register (&sprd_eic_irq_notifier, - &sprd_eic->irq_nb); -if (ret) -return dev_err_probe (dev, ret, -"Failed to register with the interrupt notifier" ); - -return devm_add_action_or_reset (dev, sprd_eic_unregister_notifier, - &sprd_eic->irq_nb); +return devm_atomic_notifier_chain_register (dev, &sprd_eic_irq_notifier, + &sprd_eic->irq_nb); }static const struct of_device_id sprd_eic_of_match[] = {
Signature · 1 line
2.47.3
PATCH v5 12/13 gpio: gpiolib-kunit: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the gpio_unbind_unregister_notifier() callback.
--- drivers/gpio/gpiolib-kunit.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/gpio/gpiolib-kunit.c +2 -12
@@ -237,13 +237,6 @@ static int gpio_unbind_notify(struct notifier_block *nb, unsigned long action,return NOTIFY_OK ; } -static void gpio_unbind_unregister_notifier (void *data) -{ -struct notifier_block *nb = data; - -blocking_notifier_chain_unregister (&gpio_unbind_notifier, nb); -} -static int gpio_unbind_consumer_probe (struct platform_device *pdev) {struct gpio_unbind_consumer_drvdata *data;
@@ -261,11 +254,8 @@ static int gpio_unbind_consumer_probe(struct platform_device *pdev)return PTR_ERR (data->desc); data->nb.notifier_call = gpio_unbind_notify; - ret =blocking_notifier_chain_register (&gpio_unbind_notifier, &data->nb); -if (ret) -return ret; - - ret =devm_add_action_or_reset (dev, gpio_unbind_unregister_notifier, &data->nb); + ret =devm_blocking_notifier_chain_register (dev, &gpio_unbind_notifier, + &data->nb);if (ret)return ret;
Signature · 1 line
2.47.3
PATCH v5 13/13 reboot: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberReplace 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.
---
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
@@ -136,30 +136,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
[email protected]
AI reviewRe: [PATCH v5 07/13] Input: adp5585: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a potential NULL pointer dereference due to an unchecked platform_get_device_id() return value. --
--- Patch [7]: [PATCH v5 07/13] Input: adp5585: use devm_blocking_notifier_chain_register() --- commit 7fdada2980ba610dca31ca2b97c993a21524a85f
Author: Eliav Farber <[email protected]>
Input: adp5585: use devm_blocking_notifier_chain_register()
This commit replaces the manual registration and devm cleanup of the blocking notifier chain with a single call to devm_blocking_notifier_chain_register().
Quoted 4 lines
drivers/input/keyboard/adp5585-keys.c +0
-0
[ ... ]
Quoted 3 lines
static int
adp5585_keys_probe(struct platform_device *pdev)
{
const structplatform_device_id*id =platform_get_device_id(pdev);
[Severity: High]
This isn't a bug introduced by this patch, but is it possible for platform_get_device_id() to return a null pointer here and cause a panic when id->driver_data is dereferenced?
Looking at adp5585_keys_probe(), the returned id is not checked before accessing id->driver_data:
drivers/input/keyboard/adp5585-keys.c:adp5585_keys_probe() {
const struct platform_device_id *id = platform_get_device_id(pdev);
...
kpad->info = (const struct adp5585_kpad_chip *)id->driver_data;
}If a privileged user writes an arbitrary string to the driver_override sysfs attribute of a platform device and binds it to this driver, platform_get_device_id() will return null because the bound device name doesn't match the driver's id_table. Does this code need a null pointer check to prevent a local denial of service?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
[email protected]
AI reviewRe: [PATCH v5 05/13] gpio: adp5585: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The device-managed event notifier is registered before the gpiochip is added, leading to a Use-After-Free of the IRQ domain during device teardown. --
--- Patch [5]: [PATCH v5 05/13] gpio: adp5585: use devm_blocking_notifier_chain_register() --- commit c5fe212287473e8e21c8d2bae802d7b8fa665fcd
Author: Eliav Farber <[email protected]>
gpio: adp5585: use devm_blocking_notifier_chain_register()
This commit replaces the manual registration of a blocking notifier and its associated devm_add_action_or_reset() cleanup with the new devm_blocking_notifier_chain_register() helper.
Quoted 4 lines
drivers/gpio/gpio-adp5585.c +0
-0
[ ... ]
Quoted 4 lines
drivers/gpio/gpio-adp5585.c +0
-0@@ -450,13 +440,9 @@ static int adp5585_gpio_probe(struct platform_device *pdev) girq->threaded = true; adp5585_gpio->nb.notifier_call = adp5585_gpio_key_event;
drivers/gpio/gpio-adp5585.c static int adp5585_gpio_probe(struct platform_device *pdev) · line 445
Quoted 10 lines
drivers/gpio/gpio-adp5585.c +3
-7- ret =blocking_notifier_chain_register (&adp5585->event_notifier, - &adp5585_gpio->nb); -if (ret) -return ret; - - ret =devm_add_action_or_reset (dev, adp5585_gpio_unreg_notifier, - adp5585_gpio); + ret =devm_blocking_notifier_chain_register (dev, + &adp5585->event_notifier, + &adp5585_gpio->nb);
[Severity: High]
This is a pre-existing issue, but does this devres registration order leave a use-after-free window during device unbind?
Because devm_blocking_notifier_chain_register() is called before devm_gpiochip_add_data() (which happens later in adp5585_gpio_probe), devres will destroy the gpiochip and its IRQ domain before unregistering this notifier during device teardown.
If the user unbinds the adp5585-gpio child device via sysfs while the parent device remains bound, and a hardware interrupt fires on the parent device during this teardown window, the parent's IRQ handler executes adp5585_gpio_key_event(). This dereferences the already freed irq.domain pointer:
adp5585_gpio_key_event() {
...
irq = irq_find_mapping(adp5585_gpio->gpio_chip.irq.domain, off);
...
}Quoted 3 lines
drivers/gpio/gpio-adp5585.c +0
-0if (ret)return ret; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH v5 01/13] notifier: add device-managed registration APIs
In reply to Eliav FarberThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] The patch omits explicitly callable devm_*_unregister() functions, preventing safe early…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The patch omits explicitly callable devm_*_unregister() functions, preventing safe early unregistration in drivers.
- [Medium] devm_atomic_notifier_chain_register() is implicitly restricted to process context but its documentation does not state this.
- [Low] Device-managed registration for SRCU notifiers is omitted without justification.
--
--- Patch [1]: [PATCH v5 01/13] notifier: add device-managed registration APIs --- commit 123931abf8d80f91fce35443259e0df9e2736a4e
Author: Eliav Farber <[email protected]>
notifier: add device-managed registration APIs
This patch adds devm_atomic_notifier_chain_register() and devm_blocking_notifier_chain_register() that automatically unregister the notifier when the device is unbound. This reduces boilerplate in drivers by eliminating per-driver unregister callbacks.
Quoted 4 lines
include/linux/notifier.h +0
-0
[ ... ]
include/linux/notifier.h extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); · line 151
Quoted 7 lines
include/linux/notifier.h +3
-0@@ -145,8 +146,14 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);extern int atomic_notifier_chain_register (struct atomic_notifier_head *nh,struct notifier_block *nb); +int devm_atomic_notifier_chain_register (struct device *dev, +struct atomic_notifier_head *nh, +struct notifier_block *nb);
[Severity: Medium]
Should there be corresponding devm_atomic_notifier_chain_unregister() and devm_blocking_notifier_chain_unregister() functions provided?
If a driver needs to unregister early to quiesce hardware, manually calling the non-devm unregister function leaves a stale devres action. This performs a useless double-unregister during devres_release_all(), which unconditionally hits the slow synchronize_rcu() and delays unbind.
include/linux/notifier.h extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); · line 159
Quoted 8 lines
include/linux/notifier.h +3
-0extern int blocking_notifier_chain_register (struct blocking_notifier_head *nh,struct notifier_block *nb); +int devm_blocking_notifier_chain_register (struct device *dev, +struct blocking_notifier_head *nh, +struct notifier_block *nb);extern int raw_notifier_chain_register (struct raw_notifier_head *nh,struct notifier_block *nb); extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
[Severity: Low]
Is there a reason the devm variant for SRCU notifiers was omitted?
The commit message justifies omitting raw notifiers due to locking constraints, but SRCU notifiers manage their own internal mutex which should be safe to lock in the devres teardown context.
Quoted 4 lines
kernel/notifier.c +0
-0
[ ... ]
Quoted 18 lines
kernel/notifier.c +14
-0@@ -197,6 +198,56 @@ int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, }EXPORT_SYMBOL_GPL (atomic_notifier_chain_unregister); +struct atomic_notifier_chain_devres { +struct atomic_notifier_head *nh; +struct notifier_block *nb; +}; + +static void devm_atomic_notifier_chain_unregister (struct device *dev,void *res) +{ +struct atomic_notifier_chain_devres *dr = res; + +atomic_notifier_chain_unregister (dr->nh, dr->nb); +} + +/** +* devm_atomic_notifier_chain_register - Device-managed atomic notifier registration
kernel/notifier.c int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, · line 224
Quoted 10 lines
kernel/notifier.c +10
-0+* @dev: Device to tie the notifier lifetime to +* @nh: Pointer to head of the atomic notifier chain +* @nb: New entry in notifier chain +* +* Adds a notifier to an atomic notifier chain and registers a cleanup +* action to automatically unregister it when @dev is unbound. +* +* Return: +* 0 on success, negative errno on error. +*/
[Severity: Medium]
Should this kerneldoc include a context warning like "Must be called in process context."?
Unlike atomic_notifier_chain_register() which is safe in atomic context, this function uses devres_alloc() with GFP_KERNEL which can sleep, making it unsafe to call from atomic context.
Quoted 3 lines
kernel/notifier.c +3
-0+int devm_atomic_notifier_chain_register (struct device *dev, +struct atomic_notifier_head *nh, +struct notifier_block *nb)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v5 01/13] notifier: add device-managed registration APIs
Hello Eliav,
Quoted 26 lines · On Sun, Aug 16, 2026 at 06:19:06AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The patch omits explicitly callable devm_*_unregister() functions, preventing safe early unregistration in drivers.
- [Medium]devm_atomic_notifier_chain_register()is implicitly restricted to process context but its documentation does not state this.
- [Low] Device-managed registration for SRCU notifiers is omitted without justification.
----- Patch [1]: [PATCH v5 01/13] notifier: add device-managed registration APIs --- commit
123931abf8d80f91fce35443259e0df9e2736a4e
Author: Eliav Farber <[email protected]>notifier: add device-managed registration APIs
This patch adds
devm_atomic_notifier_chain_register()anddevm_blocking_notifier_chain_register()that automatically unregister the notifier when the device is unbound. This reduces boilerplate in drivers by eliminating per-driver unregister callbacks.Quoted 4 lines
include/linux/notifier.h +0
-0[ ... ]
Quoted 2 lines
include/linux/notifier.h +0
-0@@ -145,8 +146,14 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
Quoted 9 lines
include/linux/notifier.h extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); · line 151
Quoted 5 lines
include/linux/notifier.h +3
-0extern int atomic_notifier_chain_register (struct atomic_notifier_head *nh,struct notifier_block *nb); +int devm_atomic_notifier_chain_register (struct device *dev, +struct atomic_notifier_head *nh, +struct notifier_block *nb);[Severity: Medium]
Should there be correspondingdevm_atomic_notifier_chain_unregister()anddevm_blocking_notifier_chain_unregister()functions provided?
I think these can be added once they are needed.
Quoted 17 lines
If a driver needs to unregister early to quiesce hardware, manually calling the non-devm unregister function leaves a stale devres action. This performs a useless double-unregister during
devres_release_all(), which unconditionally hits the slowsynchronize_rcu()and delays unbind.include/linux/notifier.h extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); · line 159
Quoted 8 lines
include/linux/notifier.h +3
-0extern int blocking_notifier_chain_register (struct blocking_notifier_head *nh,struct notifier_block *nb); +int devm_blocking_notifier_chain_register (struct device *dev, +struct blocking_notifier_head *nh, +struct notifier_block *nb);extern int raw_notifier_chain_register (struct raw_notifier_head *nh,struct notifier_block *nb); extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,[Severity: Low]
Is there a reason the devm variant for SRCU notifiers was omitted?
Quoted 3 lines
The commit message justifies omitting raw notifiers due to locking constraints, but SRCU notifiers manage their own internal mutex which should be safe to lock in the devres teardown context.
🤷, I don't care much.
Quoted 41 lines
Quoted 5 lines
kernel/notifier.c +0
-0[ ... ]
Quoted 18 lines
kernel/notifier.c +14
-0@@ -197,6 +198,56 @@ int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, }EXPORT_SYMBOL_GPL (atomic_notifier_chain_unregister); +struct atomic_notifier_chain_devres { +struct atomic_notifier_head *nh; +struct notifier_block *nb; +}; + +static void devm_atomic_notifier_chain_unregister (struct device *dev,void *res) +{ +struct atomic_notifier_chain_devres *dr = res; + +atomic_notifier_chain_unregister (dr->nh, dr->nb); +} + +/** +* devm_atomic_notifier_chain_register - Device-managed atomic notifier registration kernel/notifier.c int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, · line 224
Quoted 10 lines
kernel/notifier.c +10
-0+* @dev: Device to tie the notifier lifetime to +* @nh: Pointer to head of the atomic notifier chain +* @nb: New entry in notifier chain +* +* Adds a notifier to an atomic notifier chain and registers a cleanup +* action to automatically unregister it when @dev is unbound. +* +* Return: +* 0 on success, negative errno on error. +*/ [Severity: Medium]
Should this kerneldoc include a context warning like "Must be called in process context."?
Quoted 3 lines
Unlike
atomic_notifier_chain_register()which is safe in atomic context, this function usesdevres_alloc()withGFP_KERNELwhich can sleep, making it unsafe to call from atomic context.
That sounds like a good suggestion.
You didn't specify a merge plan for this series. Given there is no explicit maintainer for kernel/notifier.c, I can apply patch #1 (with adding the comment suggested by Sashiko) and provide an immutable branch for subsystem maintainers to pull into their tree as base to apply their patches. I'd wait till say Wednesday with that to maybe let reviews tickle in.
Sounds good?
Best regards
Uwe
Uwe Kleine-König
maintainerRe: [PATCH v5 01/13] notifier: add device-managed registration APIs
In reply to Eliav FarberHello,
I already replied to Sashiko's review and only noticed afterwards that this way most recipients are stripped. So here again for the wide audience:
I suggested to add "Must be called in process context." to the kdoc for devm_atomic_notifier_chain_register() as this is a relevant difference to atomic_notifier_chain_register() and create an immutable branch for it as a base for subsystems to apply their follow-up patches. I'd wait till Wednesday for concerns and review tags to tickle in.
Best regards
Uwe
Re: [PATCH v5 01/13] notifier: add device-managed registration APIs
In reply to Uwe Kleine-KönigQuoted 1 line
🤷, I don't care much.
I'm surprised how emojis can be used in the lkml...
btw I can't review this series (much) because this seems to be like for something
else
But the least I can do:
A-B instead of R-B because I haven't done vigorous review.
Also, I added akpm because he (sorta) maintains reboot.c for instance...
We should really add a formal maintainer/reviewer slot for these files. I don't mind taking it up, but reboot.c ATM is quite nuts.....
Btw, thanks for your patch Eliav
Thanks!
Re: [PATCH v5 01/13] notifier: add device-managed registration APIs
In reply to Uwe Kleine-KönigQuoted 5 lines · Uwe Kleine-König
I suggested to add "Must be called in process context." to the kdoc for
devm_atomic_notifier_chain_register()as this is a relevant difference toatomic_notifier_chain_register()and create an immutable branch for it as a base for subsystems to apply their follow-up patches. I'd wait till Wednesday for concerns and review tags to tickle in.
I think this is a good approach, but we are in the merge window, don't you wanna wait for v7.3-rc1 and create the immutable branch based on that?
(But Bartosz will be the one pulling the immutable branch...)
Yours,
Linus Walleij
Re: [PATCH v5 05/13] gpio: adp5585: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberQuoted 7 lines · Eliav Farber
Replace the
blocking_notifier_chain_register()+devm_add_action_or_reset()pattern with a single call todevm_blocking_notifier_chain_register(), removing theadp5585_gpio_unreg_notifier()callback.Signed-off-by Eliav Farber <[email protected]>
Sashikos comment is probably correct but can be fixed in another patch by whoever wants to.
Yours,
Linus Walleij
Re: [PATCH v5 11/13] gpio: eic-sprd: use devm_atomic_notifier_chain_register()
In reply to Eliav FarberQuoted 8 lines · Eliav Farber
Replace the
atomic_notifier_chain_register()+devm_add_action_or_reset()pattern with a single call todevm_atomic_notifier_chain_register(), removing thesprd_eic_unregister_notifier()callback.Signed-off-by Eliav Farber <[email protected]>Reviewed-by Baolin Wang <[email protected]>
Yours,
Linus Walleij
Re: [PATCH v5 12/13] gpio: gpiolib-kunit: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberQuoted 7 lines · Eliav Farber
Replace the
blocking_notifier_chain_register()+devm_add_action_or_reset()pattern with a single call todevm_blocking_notifier_chain_register(), removing thegpio_unbind_unregister_notifier()callback.Signed-off-by Eliav Farber <[email protected]>
Yours,
Linus Walleij
Uwe Kleine-König
maintainerRe: [PATCH v5 01/13] notifier: add device-managed registration APIs
In reply to Linus WalleijHello Linus,
Quoted 11 lines · Linus Walleij
Quoted 5 lines · Uwe Kleine-König
I suggested to add "Must be called in process context." to the kdoc for
devm_atomic_notifier_chain_register()as this is a relevant difference toatomic_notifier_chain_register()and create an immutable branch for it as a base for subsystems to apply their follow-up patches. I'd wait till Wednesday for concerns and review tags to tickle in.I think this is a good approach, but we are in the merge window, don't you wanna wait for v7.3-rc1 and create the immutable branch based on that?
My thought was to base on v7.2, and then consider the topic done for me.
Quoted 1 line
(But Bartosz will be the one pulling the immutable branch...)
It shouldn't make a difference for him if the branch's base is v7.2 or v7.3-rc1, still more given that there are no changes staged in next to the affected files (git log v7.2..next/master -- include/linux/notifier.h kernel/notifier.c).
Best regards
Uwe
Uwe Kleine-König
maintainer[GIT PULL] Base commit for devm_{atomic,blocking}_notifier_chain_register()
In reply to Eliav FarberHello,
Quoted 8 lines · Eliav Farber
Many drivers repeat the same boilerplate when registering notifiers with device lifetime:
1. Register the notifier with
*_notifier_chain_register()
2. Check for error
3. Register a devm action to unregister on teardown
4. Implement a per-driver static unregister callback
Quoted 4 lines
This series adds
devm_atomic_notifier_chain_register()anddevm_blocking_notifier_chain_register()that automatically unregister the notifier when the device is unbound, then converts 11 drivers to use them.
I applied the first patch on top of v7.2 for you to merge into your subsystem trees as base for applying the patch(es) from this series that should go via your tree.
Find it at
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git tags/devm_notifier_chain_register-for-7.3
This tag only contains this single commit e38b9eda475f ("notifier: add device-managed registration APIs"). I intend to include it in my PR for v7.3-rc1, feel free to do the same.
Best regards
Uwe
Uwe Kleine-König
maintainerRe: [GIT PULL] Base commit for devm_{atomic,blocking}_notifier_chain_register()
Quoted 18 lines · Uwe Kleine-König
Quoted 8 lines · Eliav Farber
Many drivers repeat the same boilerplate when registering notifiers with device lifetime:
1. Register the notifier with
*_notifier_chain_register()
2. Check for error
3. Register a devm action to unregister on teardown
4. Implement a per-driver static unregister callbackQuoted 4 lines
This series adds
devm_atomic_notifier_chain_register()anddevm_blocking_notifier_chain_register()that automatically unregister the notifier when the device is unbound, then converts 11 drivers to use them.I applied the first patch on top of v7.2 for you to merge into your subsystem trees as base for applying the patch(es) from this series that should go via your tree.
Quoted 7 lines
Find it at
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git tags/devm_notifier_chain_register-for-7.3
This tag only contains this single commit
e38b9eda475f("notifier: add device-managed registration APIs"). I intend to include it in my PR for v7.3-rc1, feel free to do the same.
While I tried to pick up the pwm patch in this series I noticed my Arithmetic error here 🙄. It should be 7.4 of course. I created
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git tags/devm_notifier_chain_register-for-7.4
with a fixed tag message and dropped the 7.3 tag. (Even is someone already pulled it, nothing bad happens as it points to the same commit.)
Sorry for the confusion.
Uwe
Uwe Kleine-König
maintainerRe: [PATCH v5 02/13] pwm: iqs620a: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberHello,
Quoted 6 lines · Eliav Farber
Replace the
blocking_notifier_chain_register()+devm_add_action_or_reset()pattern with a single call todevm_blocking_notifier_chain_register(), removing theiqs620_pwm_notifier_unregister()callback.Signed-off-by Eliav Farber <[email protected]>
I applied this to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-nexxt
(with $Subject ~= s/use/Use/ to match the usual style in pwm land) as 7.4 material. Note this branch isn't stable and I intend to rebase it to 7.3-rc1 once that is available. Until then it will also not be part of linux-next.
Best regards
Uwe
Bartosz Golaszewski
AppliedRe: (subset) [PATCH v5 00/13] notifier: add device-managed registration APIs and convert drivers
In reply to Eliav FarberQuoted 9 lines · Eliav Farber
Many drivers repeat the same boilerplate when registering notifiers with device lifetime:
1. Register the notifier with
*_notifier_chain_register()
2. Check for error
3. Register a devm action to unregister on teardown
4. Implement a per-driver static unregister callback[...]
Applied, thanks!
[05/13] gpio: adp5585: use devm_blocking_notifier_chain_register()
https://git.kernel.org/brgl/c/870f46a42afdc65d39587d2c56cf35eca294d201 [11/13] gpio: eic-sprd: use devm_atomic_notifier_chain_register() https://git.kernel.org/brgl/c/32390690610190f63a31f92ca555077f7861657c [12/13] gpio: gpiolib-kunit: use devm_blocking_notifier_chain_register() https://git.kernel.org/brgl/c/df6501bf6fc4b16c9f502a7ab8e785ec91f3f7e3
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
Jonathan Cameron
maintainerRe: [PATCH v5 03/13] iio: light: iqs621-als: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberQuoted 7 lines · On Sun, 16 Aug 2026 06:06:02 +0000 Eliav Farber <[email protected]> wrote:
Replace the
blocking_notifier_chain_register()+devm_add_action_or_reset()pattern with a single call todevm_blocking_notifier_chain_register(), removing theiqs621_als_notifier_unregister()callback.Signed-off-by Eliav Farber <[email protected]>Acked-by Jonathan Cameron <[email protected]>
Applied (on top of merging the branch) to the testing branch of iio.git Upgraded that ack to an SoB as a result.
Quoted 51 lines
--- drivers/iio/light/iqs621-als.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)drivers/iio/light/iqs621-als.c +3
-21@@ -179,19 +179,6 @@ static int iqs621_als_notifier(struct notifier_block *notifier,return NOTIFY_OK ; } -static void iqs621_als_notifier_unregister (void *context) -{ -struct iqs621_als_private *iqs621_als = context; -struct iio_dev *indio_dev = iqs621_als->indio_dev; -int ret; - - ret =blocking_notifier_chain_unregister (&iqs621_als->iqs62x->nh, - &iqs621_als->notifier); -if (ret) -dev_err (indio_dev->dev.parent, -"Failed to unregister notifier: %d\n" , ret); -} -static int iqs621_als_read_raw (struct iio_dev *indio_dev,struct iio_chan_spec const *chan,int *val,int *val2,long mask)@@ -563,19 +550,14 @@ static int iqs621_als_probe(struct platform_device *pdev)mutex_init (&iqs621_als->lock); iqs621_als->notifier.notifier_call = iqs621_als_notifier; - ret =blocking_notifier_chain_register (&iqs621_als->iqs62x->nh, - &iqs621_als->notifier); + ret =devm_blocking_notifier_chain_register (&pdev->dev, + &iqs621_als->iqs62x->nh, + &iqs621_als->notifier);if (ret) {dev_err (&pdev->dev,"Failed to register notifier: %d\n" , ret);return ret; } - ret =devm_add_action_or_reset (&pdev->dev, - iqs621_als_notifier_unregister, - iqs621_als); -if (ret) -return ret; -return devm_iio_device_register (&pdev->dev, indio_dev); }
Jonathan Cameron
maintainerRe: [PATCH v5 04/13] iio: position: iqs624: use devm_blocking_notifier_chain_register()
In reply to Eliav FarberQuoted 7 lines · On Sun, 16 Aug 2026 06:06:03 +0000 Eliav Farber <[email protected]> wrote:
Replace the
blocking_notifier_chain_register()+devm_add_action_or_reset()pattern with a single call todevm_blocking_notifier_chain_register(), removing theiqs624_pos_notifier_unregister()callback.Signed-off-by Eliav Farber <[email protected]>Acked-by Jonathan Cameron <[email protected]>
Applied to the testing branch of iio.git
Thanks,
Jonathan