]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ACPI: battery: allocate driver data through devm_ APIs
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 4 Sep 2024 07:12:53 +0000 (09:12 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 7 Oct 2024 16:45:18 +0000 (18:45 +0200)
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>
drivers/acpi/battery.c

index 27a55283d213764fd1e40f7a8b60d9ebe7e11662..151726a89a891d9675ed57a6882c02960bde838a 100644 (file)
@@ -1218,7 +1218,7 @@ static int acpi_battery_add(struct acpi_device *device)
        if (device->dep_unmet)
                return -EPROBE_DEFER;
 
-       battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
+       battery = devm_kzalloc(&device->dev, sizeof(*battery), GFP_KERNEL);
        if (!battery)
                return -ENOMEM;
        battery->device = device;
@@ -1258,7 +1258,6 @@ fail:
        sysfs_remove_battery(battery);
        mutex_destroy(&battery->lock);
        mutex_destroy(&battery->sysfs_lock);
-       kfree(battery);
 
        return result;
 }
@@ -1281,7 +1280,6 @@ static void acpi_battery_remove(struct acpi_device *device)
 
        mutex_destroy(&battery->lock);
        mutex_destroy(&battery->sysfs_lock);
-       kfree(battery);
 }
 
 #ifdef CONFIG_PM_SLEEP