ACPI / dock: Pass ACPI device pointer to acpi_device_is_battery()
Since we already know what the device's PNP IDs are when
acpi_device_is_battery() is called, it is not necessary to run
acpi_get_object_info() for the device in that function. Instead, if
acpi_device_is_battery() is passed a pointer to a struct acpi_device
object, it can use the list of PNP IDs from that object, so make that
happen and modify the function's header accordingly
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index ec12d97..518aae4 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1662,24 +1662,22 @@
return acpi_ata_match(phandle);
}
-bool acpi_device_is_battery(acpi_handle handle)
+bool acpi_device_is_battery(struct acpi_device *adev)
{
- struct acpi_device_info *info;
- bool ret = false;
+ struct acpi_hardware_id *hwid;
- if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info)))
- return false;
+ list_for_each_entry(hwid, &adev->pnp.ids, list)
+ if (!strcmp("PNP0C0A", hwid->id))
+ return true;
- if (info->valid & ACPI_VALID_HID)
- ret = !strcmp("PNP0C0A", info->hardware_id.string);
-
- kfree(info);
- return ret;
+ return false;
}
-static bool is_ejectable_bay(acpi_handle handle)
+static bool is_ejectable_bay(struct acpi_device *adev)
{
- if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(handle))
+ acpi_handle handle = adev->handle;
+
+ if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(adev))
return true;
return acpi_bay_match(handle);
@@ -1989,7 +1987,7 @@
{
struct acpi_hardware_id *hwid;
- if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev->handle)) {
+ if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) {
acpi_dock_add(adev);
return;
}