[PATCH 00/12] notifier: add device-managed registration APIs and convert drivers

Eliav Farber <[email protected]>
Newsgroups gmane.linux.acpi.devel,gmane.linux.kernel,gmane.linux.kernel.gpio,gmane.linux.pwm,gmane.linux.kernel.iio,gmane.linux.kernel.input,gmane.linux.drivers.platform.x86.devel
Message-ID <[email protected]>
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(),
devm_blocking_notifier_chain_register(), and
devm_raw_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.

Checkpatch reports 6 CHECKs (0 errors, 0 warnings) on patch 1:
- "extern prototypes should be avoided in .h files"
- "Alignment should match open parenthesis"

Both are intentional to match the existing coding style in notifier.h,
where all declarations use 'extern' and tab-indented continuation lines.

Eliav Farber (12):
  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: 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                   |  15 +-
 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                  |  21 +--
 include/linux/notifier.h                   |  10 ++
 kernel/notifier.c                          | 151 +++++++++++++++++++++
 kernel/reboot.c                            |  24 +---
 13 files changed, 191 insertions(+), 181 deletions(-)

-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.