Skip to content

Commit caf89d7

Browse files
t-8chopsiff
authored andcommitted
ACPI: battery: initialize mutexes through devm_ APIs
[ Upstream commit 0710c1c ] 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: 399dbca ("ACPI: battery: Add synchronization between interface updates") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit e6c83bbb0119f00f6176315489bb04e2e254af30)
1 parent 98d57d8 commit caf89d7

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

drivers/acpi/battery.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,8 @@ static int acpi_battery_add(struct acpi_device *device)
12101210
strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
12111211
strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12121212
device->driver_data = battery;
1213-
mutex_init(&battery->lock);
1214-
mutex_init(&battery->sysfs_lock);
1213+
devm_mutex_init(&device->dev, &battery->lock);
1214+
devm_mutex_init(&device->dev, &battery->sysfs_lock);
12151215
if (acpi_has_method(battery->device->handle, "_BIX"))
12161216
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
12171217

@@ -1239,8 +1239,6 @@ static int acpi_battery_add(struct acpi_device *device)
12391239
unregister_pm_notifier(&battery->pm_nb);
12401240
fail:
12411241
sysfs_remove_battery(battery);
1242-
mutex_destroy(&battery->lock);
1243-
mutex_destroy(&battery->sysfs_lock);
12441242

12451243
return result;
12461244
}
@@ -1260,9 +1258,6 @@ static void acpi_battery_remove(struct acpi_device *device)
12601258
device_init_wakeup(&device->dev, 0);
12611259
unregister_pm_notifier(&battery->pm_nb);
12621260
sysfs_remove_battery(battery);
1263-
1264-
mutex_destroy(&battery->lock);
1265-
mutex_destroy(&battery->sysfs_lock);
12661261
}
12671262

12681263
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)