From patchwork Fri Jul 31 21:38:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 38613 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 n6VLdAAB017521 for ; Fri, 31 Jul 2009 21:39:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753305AbZGaVi4 (ORCPT ); Fri, 31 Jul 2009 17:38:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753202AbZGaViz (ORCPT ); Fri, 31 Jul 2009 17:38:55 -0400 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:2434 "EHLO g5t0006.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbZGaViy (ORCPT ); Fri, 31 Jul 2009 17:38:54 -0400 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0006.atlanta.hp.com (Postfix) with ESMTP id 3F015C1E9; Fri, 31 Jul 2009 21:38:55 +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 2C0DA240B8; Fri, 31 Jul 2009 21:38:55 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id DD07A39C011; Fri, 31 Jul 2009 15:38:54 -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 R7e9Pq2MDC+G; Fri, 31 Jul 2009 15:38:51 -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 5504339C017; Fri, 31 Jul 2009 15:38:10 -0600 (MDT) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 458F926169; Fri, 31 Jul 2009 15:38:10 -0600 (MDT) Subject: [PATCH 19/19] ACPI: handle re-enumeration, when acpi_devices might already exist To: Len Brown From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org Date: Fri, 31 Jul 2009 15:38:10 -0600 Message-ID: <20090731213810.29930.29434.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 acpi_bus_scan() traverses the namespace to enumerate devices and uses acpi_add_single_object() to create acpi_devices. When the platform notifies us of a hot-plug event, we need to traverse part of the namespace again to figure out what appeared or disappeared. (We don't yet call acpi_bus_scan() during hot-plug, but I plan to do that in the future.) This patch makes acpi_add_single_object() notice when we already have an acpi_device, so we don't need to make a new one. Signed-off-by: Bjorn Helgaas --- drivers/acpi/scan.c | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 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/scan.c b/drivers/acpi/scan.c index c078390..87d3df4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1354,10 +1354,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, void *context, void **return_value) { struct acpi_bus_ops *ops = context; - struct acpi_device *device = NULL; - acpi_status status; int type; unsigned long long sta; + struct acpi_device *device; + acpi_status status; int result; result = acpi_bus_type_and_status(handle, &type, &sta); @@ -1368,13 +1368,16 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, !(sta & ACPI_STA_DEVICE_FUNCTIONING)) return AE_CTRL_DEPTH; - if (ops->acpi_op_add) - status = acpi_add_single_object(&device, handle, type, sta, - ops); - else - status = acpi_bus_get_device(handle, &device); + /* + * We may already have an acpi_device from a previous enumeration. If + * so, we needn't add it again, but we may still have to start it. + */ + device = NULL; + acpi_bus_get_device(handle, &device); + if (ops->acpi_op_add && !device) + acpi_add_single_object(&device, handle, type, sta, ops); - if (ACPI_FAILURE(status)) + if (!device) return AE_CTRL_DEPTH; if (ops->acpi_op_start && !(ops->acpi_op_add)) {