The ACPI core can register the notify handler on its own, simplifying error handling and cleanup. Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx> --- drivers/acpi/battery.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) 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), }; -- 2.46.0