Skip to contentSkip to conversation

ACPI: battery: Drop redundant checks from acpi_battery_remove()

PATCH New Rafael J. Wysocki 1 participant 1 message Feb 12 ACPI

lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 ACPI: battery: Drop redundant checks from acpi_battery_remove()

From: Rafael J. Wysocki <[email protected]>

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.

---

Applies on top of

https://web.git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?h=linux-next&id=abbdf22e0a8f23207cedf9065512620971794ff5

---
 drivers/acpi/battery.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/acpi/battery.c +1 -5
@@ -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);