]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ACPI: battery: initialize mutexes through devm_ APIs
authorThomas Weißschuh <linux@weissschuh.net>
Thu, 16 Oct 2025 13:34:36 +0000 (09:34 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Oct 2025 14:34:03 +0000 (16:34 +0200)
[ Upstream commit 0710c1ce50455ed0db91bffa0eebbaa4f69b1773 ]

Simplify the cleanup logic a bit.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://patch.msgid.link/20240904-acpi-battery-cleanups-v1-3-a3bf74f22d40@weissschuh.net
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Stable-dep-of: 399dbcadc01e ("ACPI: battery: Add synchronization between interface updates")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/acpi/battery.c

index c6e29e377b9ca3d54a6b0e949ed67fe373fd4362..1a10eeddedac1e49e81cfa9e6a12f39dbb49abe1 100644 (file)
@@ -1225,8 +1225,8 @@ static int acpi_battery_add(struct acpi_device *device)
        strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
        strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
        device->driver_data = battery;
-       mutex_init(&battery->lock);
-       mutex_init(&battery->sysfs_lock);
+       devm_mutex_init(&device->dev, &battery->lock);
+       devm_mutex_init(&device->dev, &battery->sysfs_lock);
        if (acpi_has_method(battery->device->handle, "_BIX"))
                set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
 
@@ -1254,8 +1254,6 @@ fail_pm:
        unregister_pm_notifier(&battery->pm_nb);
 fail:
        sysfs_remove_battery(battery);
-       mutex_destroy(&battery->lock);
-       mutex_destroy(&battery->sysfs_lock);
 
        return result;
 }
@@ -1275,9 +1273,6 @@ static void acpi_battery_remove(struct acpi_device *device)
        device_init_wakeup(&device->dev, 0);
        unregister_pm_notifier(&battery->pm_nb);
        sysfs_remove_battery(battery);
-
-       mutex_destroy(&battery->lock);
-       mutex_destroy(&battery->sysfs_lock);
 }
 
 #ifdef CONFIG_PM_SLEEP