Skip to content

Commit 0710c1c

Browse files
t-8chrafaeljw
authored andcommitted
ACPI: battery: initialize mutexes through devm_ APIs
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>
1 parent 909dfc6 commit 0710c1c

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
@@ -1225,8 +1225,8 @@ static int acpi_battery_add(struct acpi_device *device)
12251225
strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
12261226
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12271227
device->driver_data = battery;
1228-
mutex_init(&battery->lock);
1229-
mutex_init(&battery->sysfs_lock);
1228+
devm_mutex_init(&device->dev, &battery->lock);
1229+
devm_mutex_init(&device->dev, &battery->sysfs_lock);
12301230
if (acpi_has_method(battery->device->handle, "_BIX"))
12311231
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
12321232

@@ -1256,8 +1256,6 @@ static int acpi_battery_add(struct acpi_device *device)
12561256
unregister_pm_notifier(&battery->pm_nb);
12571257
fail:
12581258
sysfs_remove_battery(battery);
1259-
mutex_destroy(&battery->lock);
1260-
mutex_destroy(&battery->sysfs_lock);
12611259

12621260
return result;
12631261
}
@@ -1277,9 +1275,6 @@ static void acpi_battery_remove(struct acpi_device *device)
12771275
device_init_wakeup(&device->dev, 0);
12781276
unregister_pm_notifier(&battery->pm_nb);
12791277
sysfs_remove_battery(battery);
1280-
1281-
mutex_destroy(&battery->lock);
1282-
mutex_destroy(&battery->sysfs_lock);
12831278
}
12841279

12851280
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)