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 4F88091DB for ; Mon, 4 Jan 2016 21:09:51 +0100 (CET) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3pZ7NG6tgBzr3; Mon, 4 Jan 2016 21:09:50 +0100 (CET) From: Jan Viktorin To: dev@dpdk.org Date: Mon, 4 Jan 2016 21:08:16 +0100 Message-Id: <1451938106-12145-5-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1451938106-12145-1-git-send-email-viktorin@rehivetech.com> References: <1451938106-12145-1-git-send-email-viktorin@rehivetech.com> Cc: Jan Viktorin Subject: [dpdk-dev] [PATCH 04/14] eal/common: introduce function to_pci_driver 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: Mon, 04 Jan 2016 20:09:51 -0000 Signed-off-by: Jan Viktorin --- lib/librte_cryptodev/rte_cryptodev.c | 3 +-- lib/librte_eal/common/include/rte_pci.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index f09f67e..682c1aa 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -424,8 +424,7 @@ rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv, { /* Call crypto device initialization directly if device is virtual */ if (type == PMD_VDEV) - return rte_cryptodev_init((struct rte_pci_driver *)cryptodrv, - NULL); + return rte_cryptodev_init(to_pci_driver(cryptodrv), NULL); /* * Register PCI driver for physical device intialisation during diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 54d0fe2..1321654 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -82,6 +82,7 @@ extern "C" { #include #include +#include #include TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */ @@ -215,6 +216,17 @@ struct rte_pci_driver { uint32_t drv_flags; /**< Flags contolling handling of device. */ }; +static inline struct rte_pci_driver * +to_pci_driver(void *p) +{ + unsigned int *magic = (unsigned int *) p; + if (*magic == RTE_PCI_DRV_MAGIC) + return (struct rte_pci_driver *) p; + + rte_panic("%s: bad cast (%p: %08x)\n", __func__, p, *magic); + return NULL; +} + /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */ #define RTE_PCI_DRV_NEED_MAPPING 0x0001 /** Device driver must be registered several times until failure - deprecated */ -- 2.6.3