From patchwork Thu Jun 18 20:47:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 31246 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 n5IKknG6014540 for ; Thu, 18 Jun 2009 20:47:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752456AbZFRUrA (ORCPT ); Thu, 18 Jun 2009 16:47:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752546AbZFRUrA (ORCPT ); Thu, 18 Jun 2009 16:47:00 -0400 Received: from g4t0016.houston.hp.com ([15.201.24.19]:7828 "EHLO g4t0016.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456AbZFRUrA (ORCPT ); Thu, 18 Jun 2009 16:47:00 -0400 Received: from smtp1.fc.hp.com (smtp1.fc.hp.com [15.15.136.127]) by g4t0016.houston.hp.com (Postfix) with ESMTP id 0A0FD14228; Thu, 18 Jun 2009 20:47:03 +0000 (UTC) Received: from localhost.localdomain (lart.fc.hp.com [15.11.146.31]) by smtp1.fc.hp.com (Postfix) with ESMTP id BA0B9255775; Thu, 18 Jun 2009 20:11:23 +0000 (UTC) Received: from bob.kio (localhost [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id AA0A926145; Thu, 18 Jun 2009 14:47:02 -0600 (MDT) Subject: [PATCH 4/5] ACPI: pci_root: simplify list traversals To: Len Brown From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org, Alex Chiang Date: Thu, 18 Jun 2009 14:47:02 -0600 Message-ID: <20090618204702.15850.43213.stgit@bob.kio> In-Reply-To: <20090618203916.15850.7977.stgit@bob.kio> References: <20090618203916.15850.7977.stgit@bob.kio> User-Agent: StGit/0.14.3.347.g594a MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Using list_for_each_entry() makes traversing the root list easier. Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Chiang --- drivers/acpi/pci_root.c | 23 +++++++++-------------- 1 files changed, 9 insertions(+), 14 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/pci_root.c b/drivers/acpi/pci_root.c index e490a2e..d9d34e2 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -82,7 +82,7 @@ static DEFINE_MUTEX(osc_lock); int acpi_pci_register_driver(struct acpi_pci_driver *driver) { int n = 0; - struct list_head *entry; + struct acpi_pci_root *root; struct acpi_pci_driver **pptr = &sub_driver; while (*pptr) @@ -92,9 +92,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver) if (!driver->add) return 0; - list_for_each(entry, &acpi_pci_roots) { - struct acpi_pci_root *root; - root = list_entry(entry, struct acpi_pci_root, node); + list_for_each_entry(root, &acpi_pci_roots, node) { driver->add(root->device->handle); n++; } @@ -106,7 +104,7 @@ EXPORT_SYMBOL(acpi_pci_register_driver); void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) { - struct list_head *entry; + struct acpi_pci_root *root; struct acpi_pci_driver **pptr = &sub_driver; while (*pptr) { @@ -120,23 +118,19 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) if (!driver->remove) return; - list_for_each(entry, &acpi_pci_roots) { - struct acpi_pci_root *root; - root = list_entry(entry, struct acpi_pci_root, node); + list_for_each_entry(root, &acpi_pci_roots, node) driver->remove(root->device->handle); - } } EXPORT_SYMBOL(acpi_pci_unregister_driver); acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) { - struct acpi_pci_root *tmp; + struct acpi_pci_root *root; - list_for_each_entry(tmp, &acpi_pci_roots, node) { - if ((tmp->id.segment == (u16) seg) && (tmp->id.bus == (u16) bus)) - return tmp->device->handle; - } + list_for_each_entry(root, &acpi_pci_roots, node) + if ((root->id.segment == (u16) seg) && (root->id.bus == (u16) bus)) + return root->device->handle; return NULL; } @@ -325,6 +319,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags) static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) { struct acpi_pci_root *root; + list_for_each_entry(root, &acpi_pci_roots, node) { if (root->device->handle == handle) return root;