From patchwork Tue Jan 15 03:12:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 211978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1A1F32C00AA for ; Tue, 15 Jan 2013 14:14:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750912Ab3AODO4 (ORCPT ); Mon, 14 Jan 2013 22:14:56 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:4733 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916Ab3AODOz (ORCPT ); Mon, 14 Jan 2013 22:14:55 -0500 Received: from 172.24.2.119 (EHLO szxeml212-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id AVQ97022; Tue, 15 Jan 2013 11:14:32 +0800 (CST) Received: from SZXEML415-HUB.china.huawei.com (10.82.67.154) by szxeml212-edg.china.huawei.com (172.24.2.181) with Microsoft SMTP Server (TLS) id 14.1.323.3; Tue, 15 Jan 2013 11:14:30 +0800 Received: from localhost (10.135.76.69) by szxeml415-hub.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.1.323.3; Tue, 15 Jan 2013 11:14:26 +0800 From: Yijing Wang To: Bjorn Helgaas , Yu Zhao CC: Kenji Kaneshige , Scott Murray , Yinghai Lu , , Hanjun Guo , , Yijing Wang Subject: [PATCH -v3 7/7] PCI, shpchp: use bus->devices list instead of traditional traversal Date: Tue, 15 Jan 2013 11:12:22 +0800 Message-ID: <1358219542-16880-8-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 In-Reply-To: <1358219542-16880-1-git-send-email-wangyijing@huawei.com> References: <1358219542-16880-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.76.69] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Bjorn Helgaas Use bus->devices list to traverse the pci function devices when configure or unconfigure the slot like other pci hotplug drivers. Signed-off-by: Bjorn Helgaas Signed-off-by: Yijing Wang --- drivers/pci/hotplug/shpchp_pci.c | 16 +++------------- 1 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index c627ed9..0eda985 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c @@ -40,7 +40,7 @@ int __ref shpchp_configure_device(struct slot *p_slot) struct controller *ctrl = p_slot->ctrl; struct pci_dev *bridge = ctrl->pci_dev; struct pci_bus *parent = bridge->subordinate; - int num, fn; + int num; dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); if (dev) { @@ -57,25 +57,15 @@ int __ref shpchp_configure_device(struct slot *p_slot) return -ENODEV; } - for (fn = 0; fn < 8; fn++) { - dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); - if (!dev) - continue; + list_for_each_entry(dev, &parent->devices, bus_list) if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) pci_hp_add_bridge(dev); - pci_dev_put(dev); - } pci_assign_unassigned_bridge_resources(bridge); - for (fn = 0; fn < 8; fn++) { - dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); - if (!dev) - continue; + list_for_each_entry(dev, &parent->devices, bus_list) pci_configure_slot(dev); - pci_dev_put(dev); - } pci_bus_add_devices(parent);