From patchwork Mon Sep 21 19:30:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 49105 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 n8LJTrWa009260 for ; Mon, 21 Sep 2009 19:30:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753441AbZIUTaI (ORCPT ); Mon, 21 Sep 2009 15:30:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753474AbZIUTaI (ORCPT ); Mon, 21 Sep 2009 15:30:08 -0400 Received: from g1t0028.austin.hp.com ([15.216.28.35]:31562 "EHLO g1t0028.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753441AbZIUTaH (ORCPT ); Mon, 21 Sep 2009 15:30:07 -0400 Received: from g1t0039.austin.hp.com (g1t0039.austin.hp.com [16.236.32.45]) by g1t0028.austin.hp.com (Postfix) with ESMTP id 9E47D1C0CA; Mon, 21 Sep 2009 19:30:11 +0000 (UTC) Received: from ldl (linux.corp.hp.com [15.11.146.101]) by g1t0039.austin.hp.com (Postfix) with ESMTP id 820CB340F6; Mon, 21 Sep 2009 19:30:11 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 839DBCF000F; Mon, 21 Sep 2009 13:30:11 -0600 (MDT) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OiaYweEkXMnV; Mon, 21 Sep 2009 13:30:11 -0600 (MDT) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl (Postfix) with ESMTP id 6FF8BCF000D; Mon, 21 Sep 2009 13:30:11 -0600 (MDT) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 498672615C; Mon, 21 Sep 2009 13:30:11 -0600 (MDT) Subject: [PATCH v3 17/17] ACPI: handle re-enumeration, when acpi_devices might already exist To: Len Brown From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org Date: Mon, 21 Sep 2009 13:30:11 -0600 Message-ID: <20090921193011.21322.7164.stgit@bob.kio> In-Reply-To: <20090921192656.21322.23072.stgit@bob.kio> References: <20090921192656.21322.23072.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 954bd01..2c4cac5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1400,10 +1400,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); @@ -1414,13 +1414,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)) {