From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 003DA5A6A for ; Wed, 21 Jun 2017 16:28:19 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP; 21 Jun 2017 07:28:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,369,1493708400"; d="scan'208";a="100129523" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by orsmga004.jf.intel.com with ESMTP; 21 Jun 2017 07:28:18 -0700 From: Pablo de Lara To: declan.doherty@intel.com, thomas@monjalon.net Cc: dev@dpdk.org, Pablo de Lara Date: Wed, 21 Jun 2017 07:28:24 +0100 Message-Id: <20170621062826.21896-8-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170621062826.21896-1-pablo.de.lara.guarch@intel.com> References: <1495639634-74846-1-git-send-email-pablo.de.lara.guarch@intel.com> <20170621062826.21896-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 07/12] cryptodev: release device if PCI device probing fails X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 14:28:21 -0000 Call rte_cryptodev_pmd_release_device() if probing a PCI crypto device, instead of accessing the variables directly. This will be useful when rte_cryptodev_pci_probe() gets moved to a separate file. Signed-off-by: Pablo de Lara Acked-by: Declan Doherty --- lib/librte_cryptodev/rte_cryptodev.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index c0cfe94..d02a4d0 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -541,9 +541,12 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev) if (cryptodev == NULL) return -EINVAL; - ret = rte_cryptodev_close(cryptodev->data->dev_id); - if (ret < 0) - return ret; + /* Close device only if device operations have been set */ + if (cryptodev->dev_ops) { + ret = rte_cryptodev_close(cryptodev->data->dev_id); + if (ret < 0) + return ret; + } cryptodev->attached = RTE_CRYPTODEV_DETACHED; cryptodev_globals.nb_devs--; @@ -604,8 +607,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv, if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_free(cryptodev->data->dev_private); - cryptodev->attached = RTE_CRYPTODEV_DETACHED; - cryptodev_globals.nb_devs--; + /* free crypto device */ + rte_cryptodev_pmd_release_device(cryptodev); return -ENXIO; } -- 2.9.4