From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Viktorin Subject: [PATCH 05/14] eal/common: introduce function to_pci_device Date: Mon, 4 Jan 2016 21:08:17 +0100 Message-ID: <1451938106-12145-6-git-send-email-viktorin@rehivetech.com> References: <1451938106-12145-1-git-send-email-viktorin@rehivetech.com> Cc: Jan Viktorin To: dev@dpdk.org Return-path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id 53B8B91E3 for ; Mon, 4 Jan 2016 21:09:51 +0100 (CET) In-Reply-To: <1451938106-12145-1-git-send-email-viktorin@rehivetech.com> 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" Signed-off-by: Jan Viktorin --- lib/librte_eal/common/include/rte_pci.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 1321654..204ee82 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -171,6 +171,17 @@ struct rte_pci_device { enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */ }; +static inline struct rte_pci_device * +to_pci_device(void *p) +{ + unsigned int *magic = (unsigned int *) p; + if (*magic == RTE_PCI_DEVICE_MAGIC) + return (struct rte_pci_device *) p; + + rte_panic("%s: bad cast (%p: %08x)\n", __func__, p, *magic); + return NULL; +} + /** Any PCI device identifier (vendor, device, ...) */ #define PCI_ANY_ID (0xffff) -- 2.6.3