diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-02-15 18:09:34 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-02-15 19:51:15 -0500 |
commit | b43109fa466e6e29091b3e62e6a6c8a0bd099beb (patch) | |
tree | 539a7f34c0d8c37fe4c400a7dba697b0d98f33a8 /drivers/acpi/scan.c | |
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>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 24 |
1 files changed, 11 insertions, 13 deletions
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) | |||
1662 | return acpi_ata_match(phandle); | 1662 | return acpi_ata_match(phandle); |
1663 | } | 1663 | } |
1664 | 1664 | ||
1665 | bool acpi_device_is_battery(acpi_handle handle) | 1665 | bool acpi_device_is_battery(struct acpi_device *adev) |
1666 | { | 1666 | { |
1667 | struct acpi_device_info *info; | 1667 | struct acpi_hardware_id *hwid; |
1668 | bool ret = false; | ||
1669 | |||
1670 | if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info))) | ||
1671 | return false; | ||
1672 | 1668 | ||
1673 | if (info->valid & ACPI_VALID_HID) | 1669 | list_for_each_entry(hwid, &adev->pnp.ids, list) |
1674 | ret = !strcmp("PNP0C0A", info->hardware_id.string); | 1670 | if (!strcmp("PNP0C0A", hwid->id)) |
1671 | return true; | ||
1675 | 1672 | ||
1676 | kfree(info); | 1673 | return false; |
1677 | return ret; | ||
1678 | } | 1674 | } |
1679 | 1675 | ||
1680 | static bool is_ejectable_bay(acpi_handle handle) | 1676 | static bool is_ejectable_bay(struct acpi_device *adev) |
1681 | { | 1677 | { |
1682 | if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(handle)) | 1678 | acpi_handle handle = adev->handle; |
1679 | |||
1680 | if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(adev)) | ||
1683 | return true; | 1681 | return true; |
1684 | 1682 | ||
1685 | return acpi_bay_match(handle); | 1683 | return acpi_bay_match(handle); |
@@ -1989,7 +1987,7 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) | |||
1989 | { | 1987 | { |
1990 | struct acpi_hardware_id *hwid; | 1988 | struct acpi_hardware_id *hwid; |
1991 | 1989 | ||
1992 | if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev->handle)) { | 1990 | if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) { |
1993 | acpi_dock_add(adev); | 1991 | acpi_dock_add(adev); |
1994 | return; | 1992 | return; |
1995 | } | 1993 | } |