diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-02-16 00:09:34 +0100 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-02-16 01:51:15 +0100 |
commit | b43109fa466e6e29091b3e62e6a6c8a0bd099beb (patch) | |
tree | 539a7f34c0d8c37fe4c400a7dba697b0d98f33a8 | |
parent | 1e2380cd144f6a9619f72f80ad9a93268f63b8dc (diff) |
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>
-rw-r--r-- | drivers/acpi/dock.c | 2 | ||||
-rw-r--r-- | drivers/acpi/internal.h | 2 | ||||
-rw-r--r-- | drivers/acpi/scan.c | 24 |
3 files changed, 13 insertions, 15 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 44c6e6c0d545..edeb72b619fb 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -793,7 +793,7 @@ void acpi_dock_add(struct acpi_device *adev) dock_station->flags |= DOCK_IS_DOCK; if (acpi_ata_match(handle)) dock_station->flags |= DOCK_IS_ATA; - if (acpi_device_is_battery(handle)) + if (acpi_device_is_battery(adev)) dock_station->flags |= DOCK_IS_BAT; ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group); diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 00e3220febda..4d081fc1aa24 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -97,7 +97,7 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); int acpi_bind_one(struct device *dev, struct acpi_device *adev); int acpi_unbind_one(struct device *dev); bool acpi_device_is_present(struct acpi_device *adev); -bool acpi_device_is_battery(acpi_handle handle); +bool acpi_device_is_battery(struct acpi_device *adev); /* -------------------------------------------------------------------------- Power Resource diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index ec12d970d78d..518aae461a00 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1662,24 +1662,22 @@ bool acpi_bay_match(acpi_handle handle) 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; - - if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info))) - return false; + struct acpi_hardware_id *hwid; - if (info->valid & ACPI_VALID_HID) - ret = !strcmp("PNP0C0A", info->hardware_id.string); + list_for_each_entry(hwid, &adev->pnp.ids, list) + if (!strcmp("PNP0C0A", hwid->id)) + return true; - 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 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) { 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; } |