From patchwork Fri Apr 12 22:44:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2438771 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 4AFEDDF2A1 for ; Fri, 12 Apr 2013 22:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754281Ab3DLWo7 (ORCPT ); Fri, 12 Apr 2013 18:44:59 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:47045 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754054Ab3DLWo4 (ORCPT ); Fri, 12 Apr 2013 18:44:56 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r3CMiqME032730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Apr 2013 22:44:52 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3CMipWr010543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 12 Apr 2013 22:44:52 GMT Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r3CMipWC003706; Fri, 12 Apr 2013 17:44:51 -0500 Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Apr 2013 15:44:50 -0700 From: Yinghai Lu To: Bjorn Helgaas , Ram Pai Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v4 12/29] PCI: Use for_each_pci_resource() in pci_enable_dev Date: Fri, 12 Apr 2013 15:44:26 -0700 Message-Id: <1365806683-26717-13-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1365806683-26717-1-git-send-email-yinghai@kernel.org> References: <1365806683-26717-1-git-send-email-yinghai@kernel.org> X-Source-IP: ucsinet22.oracle.com [156.151.31.94] 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..c29f062 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_STD_ROM_IOV_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_STD_ROM_BRIDGE_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; }