From patchwork Thu Sep 10 16:01:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 7009 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id BB62F8D3C; Thu, 10 Sep 2015 18:02:03 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 1F1945681 for ; Thu, 10 Sep 2015 18:02:01 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 10 Sep 2015 09:01:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,505,1437462000"; d="scan'208";a="642320753" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 10 Sep 2015 09:01:50 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t8AG1n7f021667; Thu, 10 Sep 2015 17:01:49 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t8AG1nwq029851; Thu, 10 Sep 2015 17:01:49 +0100 Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id t8AG1nl7029847; Thu, 10 Sep 2015 17:01:49 +0100 From: Ferruh Yigit To: dev@dpdk.org Date: Thu, 10 Sep 2015 17:01:48 +0100 Message-Id: <1441900908-29763-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] igb_uio: use existing PCI macros X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" To get pci_dev and vf number from dev, benefit from existing macros in pci.h Signed-off-by: Ferruh Yigit --- lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c index 87293b8..9f46665 100644 --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -66,8 +66,7 @@ static ssize_t show_max_vfs(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, 10, "%u\n", - pci_num_vf(container_of(dev, struct pci_dev, dev))); + return snprintf(buf, 10, "%u\n", dev_num_vf(dev)); } static ssize_t @@ -76,7 +75,7 @@ store_max_vfs(struct device *dev, struct device_attribute *attr, { int err = 0; unsigned long max_vfs; - struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); + struct pci_dev *pdev = to_pci_dev(dev); if (0 != kstrtoul(buf, 0, &max_vfs)) return -EINVAL; @@ -95,7 +94,7 @@ store_max_vfs(struct device *dev, struct device_attribute *attr, static ssize_t show_extended_tag(struct device *dev, struct device_attribute *attr, char *buf) { - struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev); + struct pci_dev *pci_dev = to_pci_dev(dev); uint32_t val = 0; pci_read_config_dword(pci_dev, PCI_DEV_CAP_REG, &val); @@ -116,7 +115,7 @@ store_extended_tag(struct device *dev, const char *buf, size_t count) { - struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev); + struct pci_dev *pci_dev = to_pci_dev(dev); uint32_t val = 0, enable; if (strncmp(buf, "on", 2) == 0) @@ -153,7 +152,7 @@ show_max_read_request_size(struct device *dev, struct device_attribute *attr, char *buf) { - struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev); + struct pci_dev *pci_dev = to_pci_dev(dev); int val = pcie_get_readrq(pci_dev); return snprintf(buf, PCI_SYS_FILE_BUF_SIZE, "%d\n", val); @@ -165,7 +164,7 @@ store_max_read_request_size(struct device *dev, const char *buf, size_t count) { - struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev); + struct pci_dev *pci_dev = to_pci_dev(dev); unsigned long size = 0; int ret;