]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: battery: Drop redundant checks from acpi_battery_remove()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 12 Feb 2026 13:26:54 +0000 (14:26 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 13 Feb 2026 13:22:19 +0000 (14:22 +0100)
In acpi_battery_remove(), "battery" cannot be NULL because it is the
driver data of the platform device passed to that function and it has
been set by acpi_battery_probe(), so drop the redundant check of it
against NULL.

Moreover, getting the ACPI device pointer from battery->device is
slightly less overhead than using the ACPI_COMPANION() macro on the
platform device to retrieve it, so do that and drop the check of that
pointer against NULL which is also redundant.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/12836976.O9o76ZdvQC@rafael.j.wysocki
drivers/acpi/battery.c

index a094763113bcd5bf6d69aa24a63259a2cac337f2..8fbad8bc465039f99185fc275f73237b73c53379 100644 (file)
@@ -1271,13 +1271,9 @@ fail:
 
 static void acpi_battery_remove(struct platform_device *pdev)
 {
-       struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
        struct acpi_battery *battery = platform_get_drvdata(pdev);
 
-       if (!device || !battery)
-               return;
-
-       acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
+       acpi_dev_remove_notify_handler(battery->device, ACPI_ALL_NOTIFY,
                                       acpi_battery_notify);
 
        device_init_wakeup(&pdev->dev, false);