Commit 0e77e2c4 authored by Zhang Rui's avatar Zhang Rui Committed by Rafael J. Wysocki

pnpacpi: convert acpi_get_handle() to acpi_has_method()

acpi_has_method() is a new ACPI API introduced to check
the existence of an ACPI control method.

It can be used to replace acpi_get_handle() in the case that
1. the calling function doesn't need the ACPI handle of the control method.
and
2. the calling function doesn't care the reason why the method is unavailable.

Convert acpi_get_handle() to acpi_has_method()
in drivers/pnp/pnpacpi/core.c in this patch.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
CC: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 54f14c27
...@@ -239,8 +239,6 @@ static char *__init pnpacpi_get_id(struct acpi_device *device) ...@@ -239,8 +239,6 @@ static char *__init pnpacpi_get_id(struct acpi_device *device)
static int __init pnpacpi_add_device(struct acpi_device *device) static int __init pnpacpi_add_device(struct acpi_device *device)
{ {
acpi_handle temp = NULL;
acpi_status status;
struct pnp_dev *dev; struct pnp_dev *dev;
char *pnpid; char *pnpid;
struct acpi_hardware_id *id; struct acpi_hardware_id *id;
...@@ -253,8 +251,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -253,8 +251,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
* If a PnPacpi device is not present , the device * If a PnPacpi device is not present , the device
* driver should not be loaded. * driver should not be loaded.
*/ */
status = acpi_get_handle(device->handle, "_CRS", &temp); if (!acpi_has_method(device->handle, "_CRS"))
if (ACPI_FAILURE(status))
return 0; return 0;
pnpid = pnpacpi_get_id(device); pnpid = pnpacpi_get_id(device);
...@@ -271,16 +268,14 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -271,16 +268,14 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
dev->data = device; dev->data = device;
/* .enabled means the device can decode the resources */ /* .enabled means the device can decode the resources */
dev->active = device->status.enabled; dev->active = device->status.enabled;
status = acpi_get_handle(device->handle, "_SRS", &temp); if (acpi_has_method(device->handle, "_SRS"))
if (ACPI_SUCCESS(status))
dev->capabilities |= PNP_CONFIGURABLE; dev->capabilities |= PNP_CONFIGURABLE;
dev->capabilities |= PNP_READ; dev->capabilities |= PNP_READ;
if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE)) if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE))
dev->capabilities |= PNP_WRITE; dev->capabilities |= PNP_WRITE;
if (device->flags.removable) if (device->flags.removable)
dev->capabilities |= PNP_REMOVABLE; dev->capabilities |= PNP_REMOVABLE;
status = acpi_get_handle(device->handle, "_DIS", &temp); if (acpi_has_method(device->handle, "_DIS"))
if (ACPI_SUCCESS(status))
dev->capabilities |= PNP_DISABLE; dev->capabilities |= PNP_DISABLE;
if (strlen(acpi_device_name(device))) if (strlen(acpi_device_name(device)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment