From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id 989A858F1 for ; Fri, 6 May 2016 15:50:11 +0200 (CEST) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3r1Y7R2j9bz7Jb; Fri, 6 May 2016 15:50:11 +0200 (CEST) From: Jan Viktorin To: dev@dpdk.org Cc: Jan Viktorin , David Marchand , Thomas Monjalon , Bruce Richardson , Declan Doherty , jianbo.liu@linaro.org, jerin.jacob@caviumnetworks.com, Keith Wiles , Stephen Hemminger Date: Fri, 6 May 2016 15:48:06 +0200 Message-Id: <1462542490-15556-25-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1462542490-15556-1-git-send-email-viktorin@rehivetech.com> References: <1462542490-15556-1-git-send-email-viktorin@rehivetech.com> In-Reply-To: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> Subject: [dpdk-dev] [PATCH v1 24/28] ether: utilize container_of for pci_drv 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: , X-List-Received-Date: Fri, 06 May 2016 13:50:12 -0000 It is not necessary to place the rte_pci_driver at the beginning of the rte_eth_dev struct anymore as we use the container_of macro to get the parent pointer. Signed-off-by: Jan Viktorin --- lib/librte_ether/rte_ethdev.c | 4 ++-- lib/librte_ether/rte_ethdev.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 55b32da..5474523 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -236,7 +236,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, int diag; - eth_drv = (struct eth_driver *)pci_drv; + eth_drv = container_of(pci_drv, struct eth_driver, pci_drv); rte_eal_pci_device_name(&pci_dev->addr, ethdev_name, sizeof(ethdev_name)); @@ -297,7 +297,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) if (eth_dev == NULL) return -ENODEV; - eth_drv = (const struct eth_driver *)pci_dev->driver; + eth_drv = container_of(pci_dev->driver, struct eth_driver, pci_drv); /* Invoke PMD device uninit function */ if (*eth_drv->eth_dev_uninit) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index c8cbe17..622c9d8 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1813,7 +1813,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev); * Each Ethernet driver acts as a PCI driver and is represented by a generic * *eth_driver* structure that holds: * - * - An *rte_pci_driver* structure (which must be the first field). + * - An *rte_pci_driver* structure. * * - The *eth_dev_init* function invoked for each matching PCI device. * -- 2.8.0