diff mbox series

[5/5] ACPI: battery: install notify handler through ACPI core

Message ID 20240904-acpi-battery-cleanups-v1-5-a3bf74f22d40@weissschuh.net (mailing list archive)
State Rejected, archived
Headers show
Series ACPI: battery: various cleanups | expand

Commit Message

Thomas Weißschuh Sept. 4, 2024, 7:12 a.m. UTC
The ACPI core can register the notify handler on its own,
simplifying error handling and cleanup.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/acpi/battery.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 4bd746f8c0ac..88899c417f15 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1060,9 +1060,8 @@  static void acpi_battery_refresh(struct acpi_battery *battery)
 }
 
 /* Driver Interface */
-static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
+static void acpi_battery_notify(struct acpi_device *device, u32 event)
 {
-	struct acpi_device *device = data;
 	struct acpi_battery *battery = acpi_driver_data(device);
 	struct power_supply *old;
 
@@ -1241,16 +1240,8 @@  static int acpi_battery_add(struct acpi_device *device)
 
 	device_init_wakeup(&device->dev, 1);
 
-	result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
-						 acpi_battery_notify, device);
-	if (result)
-		goto fail_pm;
-
 	return 0;
 
-fail_pm:
-	device_init_wakeup(&device->dev, 0);
-	unregister_pm_notifier(&battery->pm_nb);
 fail:
 	sysfs_remove_battery(battery);
 
@@ -1266,9 +1257,6 @@  static void acpi_battery_remove(struct acpi_device *device)
 
 	battery = acpi_driver_data(device);
 
-	acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
-				       acpi_battery_notify);
-
 	device_init_wakeup(&device->dev, 0);
 	unregister_pm_notifier(&battery->pm_nb);
 	sysfs_remove_battery(battery);
@@ -1297,9 +1285,11 @@  static struct acpi_driver acpi_battery_driver = {
 	.name = "battery",
 	.class = ACPI_BATTERY_CLASS,
 	.ids = battery_device_ids,
+	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
 	.ops = {
 		.add = acpi_battery_add,
 		.remove = acpi_battery_remove,
+		.notify = acpi_battery_notify,
 		},
 	.drv.pm = pm_sleep_ptr(&acpi_battery_pm),
 };