]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ACPI: battery: Switch over to devres-based resource management
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 21 May 2026 14:02:44 +0000 (16:02 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 25 May 2026 14:43:51 +0000 (16:43 +0200)
commitca50aff41fc3ef006f0e809f455be107eb07b919
treeea1c30c1147fd3877f64c60d26800318a3325324
parent026a7835bfda409661aafd5fcdf6b97878b21dc7
ACPI: battery: Switch over to devres-based resource management

The ACPI battery driver already uses devm_kzalloc() for allocating
memory and devm_mutex_init() for mutex initialization, but it still
carries out some manual rollback in acpi_battery_probe().

Switch it over to devres-based resource management completely by
making three changes:

 * Rename acpi_battery_update_retry() to devm_acpi_battery_update_retry(),
   turn sysfs_battery_cleanup() into a devm action and modify the former
   to add it.

 * Add devm_acpi_battery_init_wakeup() for initializing the wakeup
   source and make it add a custom devm action to automatically remove
   the wakeup source registered by it.

 * Make acpi_battery_probe() use devm_acpi_install_notify_handler()
   that has just been introduced for installing an ACPI notify handler.

Note that the code ordering change related to the last of the above
changes does not matter because there is no functional dependency
between the PM notifier and the wakeup source or the ACPI notify
handler.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/10856906.nUPlyArG6x@rafael.j.wysocki
drivers/acpi/battery.c