From patchwork Fri Jul 31 21:37:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 38607 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 n6VLbBIF017264 for ; Fri, 31 Jul 2009 21:37:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752945AbZGaVhl (ORCPT ); Fri, 31 Jul 2009 17:37:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752947AbZGaVhl (ORCPT ); Fri, 31 Jul 2009 17:37:41 -0400 Received: from g4t0017.houston.hp.com ([15.201.24.20]:32636 "EHLO g4t0017.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753089AbZGaVhk (ORCPT ); Fri, 31 Jul 2009 17:37:40 -0400 Received: from g4t0018.houston.hp.com (g4t0018.houston.hp.com [16.234.32.27]) by g4t0017.houston.hp.com (Postfix) with ESMTP id C0E3F3858A; Fri, 31 Jul 2009 21:37:41 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g4t0018.houston.hp.com (Postfix) with ESMTP id A088610004; Fri, 31 Jul 2009 21:37:41 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 6A20E39C003; Fri, 31 Jul 2009 15:37:41 -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 bIWUtasjM-yU; Fri, 31 Jul 2009 15:37:40 -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 BD94439C009; Fri, 31 Jul 2009 15:37:39 -0600 (MDT) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id AFD1A26169; Fri, 31 Jul 2009 15:37:39 -0600 (MDT) Subject: [PATCH 13/19] ACPI: convert acpi_bus_scan() to operate on an acpi_handle To: Len Brown From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org Date: Fri, 31 Jul 2009 15:37:39 -0600 Message-ID: <20090731213739.29930.86177.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 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 a57a7ae..afd10b5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1343,7 +1343,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; @@ -1352,13 +1352,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 @@ -1472,7 +1475,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; } @@ -1483,16 +1486,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); @@ -1609,7 +1609,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);