From patchwork Mon Sep 21 19:29:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 49099 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 n8LJTo3o009248 for ; Mon, 21 Sep 2009 19:29:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753385AbZIUT3i (ORCPT ); Mon, 21 Sep 2009 15:29:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753415AbZIUT3i (ORCPT ); Mon, 21 Sep 2009 15:29:38 -0400 Received: from g1t0029.austin.hp.com ([15.216.28.36]:35949 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753385AbZIUT3h (ORCPT ); Mon, 21 Sep 2009 15:29:37 -0400 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g1t0029.austin.hp.com (Postfix) with ESMTP id 833EF38195; Mon, 21 Sep 2009 19:29:41 +0000 (UTC) Received: from ldl (linux.corp.hp.com [15.11.146.101]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 2022E241A0; Mon, 21 Sep 2009 19:29:41 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 0496FCF000F; Mon, 21 Sep 2009 13:29:41 -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 iDEy6g0O8jFU; Mon, 21 Sep 2009 13:29:40 -0600 (MDT) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl (Postfix) with ESMTP id E4CDBCF000D; Mon, 21 Sep 2009 13:29:40 -0600 (MDT) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id B72902615C; Mon, 21 Sep 2009 13:29:40 -0600 (MDT) Subject: [PATCH v3 11/17] ACPI: convert acpi_bus_scan() to operate on an acpi_handle To: Len Brown From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org Date: Mon, 21 Sep 2009 13:29:40 -0600 Message-ID: <20090921192940.21322.91007.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 This patch changes acpi_bus_scan() to take an acpi_handle rather than an acpi_device pointer. I plan to use acpi_bus_scan() in the hotplug path, and I'd rather not assume that notifications only go to nodes that already have acpi_devices. This will also help remove the special case for adding the root node. We currently add the root by hand before acpi_bus_scan(), but using a handle here means we can start the acpi_bus_scan() directly with the root even though it doesn't have an acpi_device yet. Note that acpi_bus_scan() currently adds and/or starts the *children* of its device argument. It doesn't do anything with the device itself. Signed-off-by: Bjorn Helgaas --- drivers/acpi/scan.c | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 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 f205b36..4fe7359 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1387,7 +1387,7 @@ end: return result; } -static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) +static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops) { acpi_status status = AE_OK; struct acpi_device *parent = NULL; @@ -1396,13 +1396,16 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) acpi_handle chandle = NULL; acpi_object_type type = 0; u32 level = 1; + int ret; - - if (!start) - return -EINVAL; - - parent = start; - phandle = start->handle; + /* + * We must have an acpi_device for the starting node already, and + * we scan its children. + */ + phandle = handle; + ret = acpi_bus_get_device(phandle, &parent); + if (ret) + return ret; /* * Parse through the ACPI namespace, identify all 'devices', and @@ -1516,7 +1519,7 @@ acpi_bus_add(struct acpi_device **child, result = acpi_add_single_object(child, handle, type, &ops); if (!result) - result = acpi_bus_scan(*child, &ops); + result = acpi_bus_scan((*child)->handle, &ops); return result; } @@ -1527,16 +1530,13 @@ int acpi_bus_start(struct acpi_device *device) int result; struct acpi_bus_ops ops; - - if (!device) - return -EINVAL; + memset(&ops, 0, sizeof(ops)); + ops.acpi_op_start = 1; result = acpi_start_single_object(device); - if (!result) { - memset(&ops, 0, sizeof(ops)); - ops.acpi_op_start = 1; - result = acpi_bus_scan(device, &ops); - } + if (!result) + result = acpi_bus_scan(device->handle, &ops); + return result; } EXPORT_SYMBOL(acpi_bus_start); @@ -1653,7 +1653,7 @@ int __init acpi_scan_init(void) result = acpi_bus_scan_fixed(); if (!result) - result = acpi_bus_scan(acpi_root, &ops); + result = acpi_bus_scan(acpi_root->handle, &ops); if (result) acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);