Commit 402ac536 authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Len Brown

ACPI: add acpi_bus_get_status_handle()

Add acpi_bus_get_status_handle() so we can get the status of a namespace
object before building a struct acpi_device.

This removes a use of "device->flags.dynamic_status", a cached indicator of
whether _STA exists.  It seems simpler and more reliable to just evaluate
_STA and catch AE_NOT_FOUND errors.
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 51a85faf
...@@ -94,36 +94,33 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) ...@@ -94,36 +94,33 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
EXPORT_SYMBOL(acpi_bus_get_device); EXPORT_SYMBOL(acpi_bus_get_device);
int acpi_bus_get_status(struct acpi_device *device) acpi_status acpi_bus_get_status_handle(acpi_handle handle,
unsigned long long *sta)
{ {
acpi_status status = AE_OK; acpi_status status;
unsigned long long sta = 0;
if (!device) status = acpi_evaluate_integer(handle, "_STA", NULL, sta);
return -EINVAL; if (ACPI_SUCCESS(status))
return AE_OK;
/* if (status == AE_NOT_FOUND) {
* Evaluate _STA if present. *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
*/ ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING;
if (device->flags.dynamic_status) { return AE_OK;
status =
acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
if (ACPI_FAILURE(status))
return -ENODEV;
STRUCT_TO_INT(device->status) = (int)sta;
} }
return status;
}
/* int acpi_bus_get_status(struct acpi_device *device)
* According to ACPI spec some device can be present and functional {
* even if the parent is not present but functional. acpi_status status;
* In such conditions the child device should not inherit the status unsigned long long sta;
* from the parent.
*/ status = acpi_bus_get_status_handle(device->handle, &sta);
else if (ACPI_FAILURE(status))
STRUCT_TO_INT(device->status) = return -ENODEV;
ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; STRUCT_TO_INT(device->status) = (int) sta;
if (device->status.functional && !device->status.present) { if (device->status.functional && !device->status.present) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
...@@ -135,10 +132,8 @@ int acpi_bus_get_status(struct acpi_device *device) ...@@ -135,10 +132,8 @@ int acpi_bus_get_status(struct acpi_device *device)
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
device->pnp.bus_id, device->pnp.bus_id,
(u32) STRUCT_TO_INT(device->status))); (u32) STRUCT_TO_INT(device->status)));
return 0; return 0;
} }
EXPORT_SYMBOL(acpi_bus_get_status); EXPORT_SYMBOL(acpi_bus_get_status);
void acpi_bus_private_data_handler(acpi_handle handle, void acpi_bus_private_data_handler(acpi_handle handle,
......
...@@ -322,6 +322,8 @@ extern void unregister_acpi_bus_notifier(struct notifier_block *nb); ...@@ -322,6 +322,8 @@ extern void unregister_acpi_bus_notifier(struct notifier_block *nb);
int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
void acpi_bus_data_handler(acpi_handle handle, void *context); void acpi_bus_data_handler(acpi_handle handle, void *context);
acpi_status acpi_bus_get_status_handle(acpi_handle handle,
unsigned long long *sta);
int acpi_bus_get_status(struct acpi_device *device); int acpi_bus_get_status(struct acpi_device *device);
int acpi_bus_get_power(acpi_handle handle, int *state); int acpi_bus_get_power(acpi_handle handle, int *state);
int acpi_bus_set_power(acpi_handle handle, int state); int acpi_bus_set_power(acpi_handle handle, int state);
......
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