Skip to content

Commit 909dfc6

Browse files
t-8chrafaeljw
authored andcommitted
ACPI: battery: allocate driver data 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-2-a3bf74f22d40@weissschuh.net Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent e7b7fe3 commit 909dfc6

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/acpi/battery.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ static int acpi_battery_add(struct acpi_device *device)
12181218
if (device->dep_unmet)
12191219
return -EPROBE_DEFER;
12201220

1221-
battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
1221+
battery = devm_kzalloc(&device->dev, sizeof(*battery), GFP_KERNEL);
12221222
if (!battery)
12231223
return -ENOMEM;
12241224
battery->device = device;
@@ -1258,7 +1258,6 @@ static int acpi_battery_add(struct acpi_device *device)
12581258
sysfs_remove_battery(battery);
12591259
mutex_destroy(&battery->lock);
12601260
mutex_destroy(&battery->sysfs_lock);
1261-
kfree(battery);
12621261

12631262
return result;
12641263
}
@@ -1281,7 +1280,6 @@ static void acpi_battery_remove(struct acpi_device *device)
12811280

12821281
mutex_destroy(&battery->lock);
12831282
mutex_destroy(&battery->sysfs_lock);
1284-
kfree(battery);
12851283
}
12861284

12871285
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)