From patchwork Fri Jul 31 21:38:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 38611 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6VLdAA9017521 for ; Fri, 31 Jul 2009 21:39:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753309AbZGaViw (ORCPT ); Fri, 31 Jul 2009 17:38:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753073AbZGaViw (ORCPT ); Fri, 31 Jul 2009 17:38:52 -0400 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:2377 "EHLO g5t0006.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753305AbZGaVit (ORCPT ); Fri, 31 Jul 2009 17:38:49 -0400 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0006.atlanta.hp.com (Postfix) with ESMTP id 448E4C326; Fri, 31 Jul 2009 21:38:50 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 1B3F2240B8; Fri, 31 Jul 2009 21:38:50 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id CBF2539C043; Fri, 31 Jul 2009 15:38:49 -0600 (MDT) X-Virus-Scanned: Debian amavisd-new at ldl.fc.hp.com Received: from ldl.fc.hp.com ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KV4odIEaljJA; Fri, 31 Jul 2009 15:38:47 -0600 (MDT) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl.fc.hp.com (Postfix) with ESMTP id 2E7A039C00E; Fri, 31 Jul 2009 15:38:00 -0600 (MDT) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 18BEB26169; Fri, 31 Jul 2009 15:38:00 -0600 (MDT) Subject: [PATCH 17/19] ACPI: add acpi_bus_get_status_handle() To: Len Brown From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org Date: Fri, 31 Jul 2009 15:38:00 -0600 Message-ID: <20090731213800.29930.73396.stgit@bob.kio> In-Reply-To: <20090731213501.29930.39957.stgit@bob.kio> References: <20090731213501.29930.39957.stgit@bob.kio> User-Agent: StGit/0.14.3.386.gb02d MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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: Bjorn Helgaas --- drivers/acpi/bus.c | 49 +++++++++++++++++++++-------------------------- include/acpi/acpi_bus.h | 2 ++ 2 files changed, 24 insertions(+), 27 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 2876fc7..e2e922d 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -93,36 +93,33 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **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; - unsigned long long sta = 0; - + acpi_status status; - if (!device) - return -EINVAL; + status = acpi_evaluate_integer(handle, "_STA", NULL, sta); + if (ACPI_SUCCESS(status)) + return AE_OK; - /* - * Evaluate _STA if present. - */ - if (device->flags.dynamic_status) { - status = - acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); - if (ACPI_FAILURE(status)) - return -ENODEV; - STRUCT_TO_INT(device->status) = (int)sta; + if (status == AE_NOT_FOUND) { + *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | + ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; + return AE_OK; } + return status; +} - /* - * According to ACPI spec some device can be present and functional - * even if the parent is not present but functional. - * In such conditions the child device should not inherit the status - * from the parent. - */ - else - STRUCT_TO_INT(device->status) = - ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | - ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; +int acpi_bus_get_status(struct acpi_device *device) +{ + acpi_status status; + unsigned long long sta; + + status = acpi_bus_get_status_handle(device->handle, &sta); + if (ACPI_FAILURE(status)) + return -ENODEV; + + STRUCT_TO_INT(device->status) = (int) sta; if (device->status.functional && !device->status.present) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " @@ -134,10 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status))); - return 0; } - EXPORT_SYMBOL(acpi_bus_get_status); void acpi_bus_private_data_handler(acpi_handle handle, diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index edca7d5..26be825 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -326,6 +326,8 @@ extern void unregister_acpi_bus_notifier(struct notifier_block *nb); int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); void acpi_bus_data_handler(acpi_handle handle, u32 function, 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_power(acpi_handle handle, int *state); int acpi_bus_set_power(acpi_handle handle, int state);