From patchwork Wed Mar 13 23:28:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2266381 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6BE524020C for ; Wed, 13 Mar 2013 23:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964903Ab3CMX3E (ORCPT ); Wed, 13 Mar 2013 19:29:04 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:51334 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964868Ab3CMX3B (ORCPT ); Wed, 13 Mar 2013 19:29:01 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2DNSRSZ026494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 13 Mar 2013 23:28:28 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2DNSRTj019238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Mar 2013 23:28:27 GMT Received: from abhmt103.oracle.com (abhmt103.oracle.com [141.146.116.55]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2DNSRSm026054; Wed, 13 Mar 2013 18:28:27 -0500 Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Mar 2013 16:28:27 -0700 From: Yinghai Lu To: Bjorn Helgaas , Ram Pai Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v3 11/27] PCI: Use for_each_pci_resource() in pci_enable_dev Date: Wed, 13 Mar 2013 16:28:06 -0700 Message-Id: <1363217302-14383-12-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363217302-14383-1-git-send-email-yinghai@kernel.org> References: <1363217302-14383-1-git-send-email-yinghai@kernel.org> X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Signed-off-by: Yinghai Lu --- drivers/pci/pci.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b099e00..c0473dc 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -440,8 +440,9 @@ static void pci_restore_bars(struct pci_dev *dev) { int i; + struct resource *res; - for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) + for_each_pci_resource(dev, res, i, PCI_NOBRIDGE_RES) pci_update_resource(dev, i); } @@ -1153,6 +1154,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags) { int err; int i, bars = 0; + struct resource *res; /* * Power state could be unknown at this point, either due to a fresh @@ -1170,12 +1172,11 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags) return 0; /* already enabled */ /* only skip sriov related */ - for (i = 0; i <= PCI_ROM_RESOURCE; i++) - if (dev->resource[i].flags & flags) - bars |= (1 << i); - for (i = PCI_BRIDGE_RESOURCES; i < DEVICE_COUNT_RESOURCE; i++) - if (dev->resource[i].flags & flags) + for_each_pci_resource(dev, res, i, PCI_NOIOV_RES) { + /* TODO: check i with bits of bars */ + if (res->flags & flags) bars |= (1 << i); + } err = do_pci_enable_device(dev, bars); if (err < 0) @@ -2557,7 +2558,7 @@ static int __pci_request_region(struct pci_dev *pdev, int bar, const char *res_n err_out: dev_warn(&pdev->dev, "BAR %d: can't reserve %pR\n", bar, - &pdev->resource[bar]); + pci_dev_resource_n(pdev, bar)); return -EBUSY; }