From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <jianfeng.tan@intel.com>
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by dpdk.org (Postfix) with ESMTP id 8E50C1B1AB
 for <dev@dpdk.org>; Thu, 28 Sep 2017 15:54:45 +0200 (CEST)
Received: from fmsmga006.fm.intel.com ([10.253.24.20])
 by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 28 Sep 2017 06:54:45 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.42,450,1500966000"; d="scan'208";a="157117673"
Received: from dpdk06.sh.intel.com ([10.67.110.196])
 by fmsmga006.fm.intel.com with ESMTP; 28 Sep 2017 06:54:43 -0700
From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: 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: Thu, 28 Sep 2017 13:55:49 +0000
Message-Id: <1506606959-76230-3-git-send-email-jianfeng.tan@intel.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1506606959-76230-1-git-send-email-jianfeng.tan@intel.com>
References: <1503654052-84730-1-git-send-email-jianfeng.tan@intel.com>
 <1506606959-76230-1-git-send-email-jianfeng.tan@intel.com>
Subject: [dpdk-dev] [PATCH v2 02/12] eal: avoid calling rte_vdev_init()
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: Thu, 28 Sep 2017 13:54:46 -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 | 21 +++++----------------
 1 file changed, 5 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..87e2bf8 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,12 @@ 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