From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <jianfeng.tan@intel.com>
Received: from mga06.intel.com (mga06.intel.com [134.134.136.31])
 by dpdk.org (Postfix) with ESMTP id 884531BBBD
 for <dev@dpdk.org>; Fri, 27 Oct 2017 03:05:27 +0200 (CEST)
Received: from orsmga004.jf.intel.com ([10.7.209.38])
 by orsmga104.jf.intel.com with ESMTP; 26 Oct 2017 18:05:27 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.44,302,1505804400"; d="scan'208";a="142703129"
Received: from dpdk06.sh.intel.com ([10.67.110.196])
 by orsmga004.jf.intel.com with ESMTP; 26 Oct 2017 18:05:24 -0700
From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: jblunck@infradead.org, bruce.richardson@intel.com,
 konstantin.ananyev@intel.com, pablo.de.lara.guarch@intel.com,
 thomas@monjalon.net, yliu@fridaylinux.org, maxime.coquelin@redhat.com,
 mtetsuyah@gmail.com, ferruh.yigit@intel.com,
 Jianfeng Tan <jianfeng.tan@intel.com>
Date: Fri, 27 Oct 2017 01:06:57 +0000
Message-Id: <1509066419-117099-3-git-send-email-jianfeng.tan@intel.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1509066419-117099-1-git-send-email-jianfeng.tan@intel.com>
References: <1507519229-80692-1-git-send-email-jianfeng.tan@intel.com>
 <1509066419-117099-1-git-send-email-jianfeng.tan@intel.com>
Subject: [dpdk-dev] [PATCH v9 2/4] eal: remove dependency on vdev
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 27 Oct 2017 01:05:27 -0000

We can call bus->plug() to avoid calling rte_vdev_init() explicitly.

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 lib/librte_eal/common/eal_common_dev.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index e251275..dda8f58 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -67,7 +67,6 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 int rte_eal_dev_attach(const char *name, const char *devargs)
 {
 	struct rte_bus *bus;
-	int ret;
 
 	if (name == NULL || devargs == NULL) {
 		RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n");
@@ -80,22 +79,13 @@ int rte_eal_dev_attach(const char *name, const char *devargs)
 			name);
 		return -EINVAL;
 	}
-	if (strcmp(bus->name, "pci") == 0)
-		return rte_eal_hotplug_add("pci", name, devargs);
-	if (strcmp(bus->name, "vdev") != 0) {
-		RTE_LOG(ERR, EAL, "Device attach is only supported for PCI and vdev devices.\n");
-		return -ENOTSUP;
-	}
+	if (strcmp(bus->name, "pci") == 0 || strcmp(bus->name, "vdev") == 0)
+		return rte_eal_hotplug_add(bus->name, name, devargs);
 
-	/*
-	 * If we haven't found a bus device the user meant to "hotplug" a
-	 * virtual device instead.
-	 */
-	ret = rte_vdev_init(name, devargs);
-	if (ret)
-		RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
-			name);
-	return ret;
+	RTE_LOG(ERR, EAL,
+		"Device attach is only supported for PCI and vdev devices.\n");
+
+	return -ENOTSUP;
 }
 
 int rte_eal_dev_detach(struct rte_device *dev)
-- 
2.7.4