From patchwork Tue Sep 18 06:22:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taku Izumi X-Patchwork-Id: 1470801 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6D0F9DF24C for ; Tue, 18 Sep 2012 06:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755817Ab2IRGW3 (ORCPT ); Tue, 18 Sep 2012 02:22:29 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:57205 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755432Ab2IRGW2 (ORCPT ); Tue, 18 Sep 2012 02:22:28 -0400 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 8CFCB3EE0BB; Tue, 18 Sep 2012 15:22:27 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 72B2445DE4F; Tue, 18 Sep 2012 15:22:27 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 44F4945DE51; Tue, 18 Sep 2012 15:22:27 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 361A11DB803F; Tue, 18 Sep 2012 15:22:27 +0900 (JST) Received: from m001.s.css.fujitsu.com (m001.s.css.fujitsu.com [10.23.4.39]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id DE0CB1DB803B; Tue, 18 Sep 2012 15:22:26 +0900 (JST) Received: from m001.css.fujitsu.com (m001 [127.0.0.1]) by m001.s.css.fujitsu.com (Postfix) with ESMTP id 785782E063A; Tue, 18 Sep 2012 15:22:26 +0900 (JST) Received: from DEUCALION (unknown [10.124.101.32]) by m001.s.css.fujitsu.com (Postfix) with SMTP id 2C3CB2E0645; Tue, 18 Sep 2012 15:22:26 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Date: Tue, 18 Sep 2012 15:22:35 +0900 From: Taku Izumi To: linux-pci@vger.kernel.org, bhelgaas@google.com Cc: linux-acpi@vger.kernel.org, kaneshige.kenji@jp.fujitsu.com, yinghai@kernel.org, jiang.liu@huawei.com Subject: [PATCH v3 4/8] ACPI, PCI: change acpi_pci_drivers' add/remove interface Message-Id: <20120918152235.fedf80b5.izumi.taku@jp.fujitsu.com> In-Reply-To: <20120918151215.59ea763b.izumi.taku@jp.fujitsu.com> References: <20120918151215.59ea763b.izumi.taku@jp.fujitsu.com> X-Mailer: Sylpheed 3.1.1 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch changes .add/.remove interfaces of acpi_pci_driver. In the current implementation acpi_handle is passed as a parameter of .add/.remove interface. However acpi_pci_root structure other than acpi_handle is more usefull. This enables us to avoid useless procedure in each acpi_pci_driver. Signed-off-by: Taku Izumi --- drivers/acpi/pci_root.c | 8 ++++---- drivers/acpi/pci_slot.c | 11 ++++++----- drivers/pci/hotplug/acpiphp_glue.c | 12 +++++++----- include/linux/acpi.h | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: Bjorn-next-0903/include/linux/acpi.h =================================================================== --- Bjorn-next-0903.orig/include/linux/acpi.h +++ Bjorn-next-0903/include/linux/acpi.h @@ -139,8 +139,8 @@ void acpi_pci_irq_disable (struct pci_de struct acpi_pci_driver { struct list_head node; - int (*add)(acpi_handle handle); - void (*remove)(acpi_handle handle); + int (*add)(struct acpi_pci_root *root); + void (*remove)(struct acpi_pci_root *root); }; int acpi_pci_register_driver(struct acpi_pci_driver *driver); Index: Bjorn-next-0903/drivers/pci/hotplug/acpiphp_glue.c =================================================================== --- Bjorn-next-0903.orig/drivers/pci/hotplug/acpiphp_glue.c +++ Bjorn-next-0903/drivers/pci/hotplug/acpiphp_glue.c @@ -382,10 +382,10 @@ static inline void config_p2p_bridge_fla /* allocate and initialize host bridge data structure */ -static void add_host_bridge(acpi_handle *handle) +static void add_host_bridge(struct acpi_pci_root *root) { struct acpiphp_bridge *bridge; - struct acpi_pci_root *root = acpi_pci_find_root(handle); + acpi_handle handle = root->device->handle; bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); if (bridge == NULL) @@ -468,11 +468,12 @@ find_p2p_bridge(acpi_handle handle, u32 /* find hot-pluggable slots, and then find P2P bridge */ -static int add_bridge(acpi_handle handle) +static int add_bridge(struct acpi_pci_root *root) { acpi_status status; unsigned long long tmp; acpi_handle dummy_handle; + acpi_handle handle = root->device->handle; /* if the bridge doesn't have _STA, we assume it is always there */ status = acpi_get_handle(handle, "_STA", &dummy_handle); @@ -490,7 +491,7 @@ static int add_bridge(acpi_handle handle /* check if this bridge has ejectable slots */ if (detect_ejectable_slots(handle) > 0) { dbg("found PCI host-bus bridge with hot-pluggable slots\n"); - add_host_bridge(handle); + add_host_bridge(root); } /* search P2P bridges under this host bridge */ @@ -588,9 +589,10 @@ cleanup_p2p_bridge(acpi_handle handle, u return AE_OK; } -static void remove_bridge(acpi_handle handle) +static void remove_bridge(struct acpi_pci_root *root) { struct acpiphp_bridge *bridge; + acpi_handle handle = root->device->handle; /* cleanup p2p bridges under this host bridge in a depth-first manner */ Index: Bjorn-next-0903/drivers/acpi/pci_slot.c =================================================================== --- Bjorn-next-0903.orig/drivers/acpi/pci_slot.c +++ Bjorn-next-0903/drivers/acpi/pci_slot.c @@ -67,8 +67,8 @@ struct acpi_pci_slot { struct list_head list; /* node in the list of slots */ }; -static int acpi_pci_slot_add(acpi_handle handle); -static void acpi_pci_slot_remove(acpi_handle handle); +static int acpi_pci_slot_add(struct acpi_pci_root *root); +static void acpi_pci_slot_remove(struct acpi_pci_root *root); static LIST_HEAD(slot_list); static DEFINE_MUTEX(slot_list_lock); @@ -295,11 +295,11 @@ walk_root_bridge(acpi_handle handle, acp * @handle: points to an acpi_pci_root */ static int -acpi_pci_slot_add(acpi_handle handle) +acpi_pci_slot_add(struct acpi_pci_root *root) { acpi_status status; - status = walk_root_bridge(handle, register_slot); + status = walk_root_bridge(root->device->handle, register_slot); if (ACPI_FAILURE(status)) err("%s: register_slot failure - %d\n", __func__, status); @@ -311,10 +311,11 @@ acpi_pci_slot_add(acpi_handle handle) * @handle: points to an acpi_pci_root */ static void -acpi_pci_slot_remove(acpi_handle handle) +acpi_pci_slot_remove(struct acpi_pci_root *root) { struct acpi_pci_slot *slot, *tmp; struct pci_bus *pbus; + acpi_handle handle = root->device->handle; mutex_lock(&slot_list_lock); list_for_each_entry_safe(slot, tmp, &slot_list, list) { Index: Bjorn-next-0903/drivers/acpi/pci_root.c =================================================================== --- Bjorn-next-0903.orig/drivers/acpi/pci_root.c +++ Bjorn-next-0903/drivers/acpi/pci_root.c @@ -87,7 +87,7 @@ int acpi_pci_register_driver(struct acpi list_add_tail(&driver->node, &acpi_pci_drivers); if (driver->add) list_for_each_entry(root, &acpi_pci_roots, node) { - driver->add(root->device->handle); + driver->add(root); n++; } mutex_unlock(&acpi_pci_root_lock); @@ -104,7 +104,7 @@ void acpi_pci_unregister_driver(struct a list_del(&driver->node); if (driver->remove) list_for_each_entry(root, &acpi_pci_roots, node) - driver->remove(root->device->handle); + driver->remove(root); mutex_unlock(&acpi_pci_root_lock); } EXPORT_SYMBOL(acpi_pci_unregister_driver); @@ -629,7 +629,7 @@ static int acpi_pci_root_start(struct ac mutex_lock(&acpi_pci_root_lock); list_for_each_entry(driver, &acpi_pci_drivers, node) if (driver->add) - driver->add(device->handle); + driver->add(root); mutex_unlock(&acpi_pci_root_lock); pci_bus_add_devices(root->bus); @@ -645,7 +645,7 @@ static int acpi_pci_root_remove(struct a mutex_lock(&acpi_pci_root_lock); list_for_each_entry(driver, &acpi_pci_drivers, node) if (driver->remove) - driver->remove(root->device->handle); + driver->remove(root); mutex_unlock(&acpi_pci_root_lock); device_set_run_wake(root->bus->bridge, false);