From patchwork Fri Apr 12 22:44:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2438851 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 E4D9ADF2A1 for ; Fri, 12 Apr 2013 22:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753997Ab3DLWo4 (ORCPT ); Fri, 12 Apr 2013 18:44:56 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:46511 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753881Ab3DLWoy (ORCPT ); Fri, 12 Apr 2013 18:44:54 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r3CMilom003819 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Apr 2013 22:44:48 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3CMilI3018439 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 12 Apr 2013 22:44:47 GMT Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3CMilmj018435; Fri, 12 Apr 2013 22:44:47 GMT Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Apr 2013 15:44:46 -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 05/29] PCI: Add is_pci_*_resource_idx() helpers Date: Fri, 12 Apr 2013 15:44:19 -0700 Message-Id: <1365806683-26717-6-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: acsinet21.oracle.com [141.146.126.237] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org According to resource pointer find out if the resource is some type resource like bridge, sriov, or std. Signed-off-by: Yinghai Lu --- include/linux/pci.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index f4da78d..14b7de4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -107,6 +107,29 @@ enum { DEVICE_COUNT_RESOURCE = PCI_NUM_RESOURCES, }; +static inline bool is_pci_std_resource_idx(int i) +{ + return i >= PCI_STD_RESOURCES && i <= PCI_STD_RESOURCE_END; +} + +static inline bool is_pci_rom_resource_idx(int i) +{ + return i == PCI_ROM_RESOURCE; +} + +static inline bool is_pci_iov_resource_idx(int i) +{ +#ifdef CONFIG_PCI_IOV + return i >= PCI_IOV_RESOURCES && i <= PCI_IOV_RESOURCE_END; +#endif + return false; +} + +static inline bool is_pci_bridge_resource_idx(int i) +{ + return i >= PCI_BRIDGE_RESOURCES && i <= PCI_BRIDGE_RESOURCE_END; +} + typedef int __bitwise pci_power_t; #define PCI_D0 ((pci_power_t __force) 0)