From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id CAF1A20F for ; Tue, 4 Jul 2017 23:43:18 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 7323C216FC; Tue, 4 Jul 2017 17:43:18 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 04 Jul 2017 17:43:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=1W6 Pu+abY1YBJ574R2dIsLd7ekWj3ucuhC1D2H90JHA=; b=dbLPcVVVlbiVUN7QuZt vexrjH9q/Z+mPb/F54X3MO+fzfkZ0jtUf03TMOVxVnwF+r/x72r8zFs9UTlJf+wR ONsBt0YJDTtxXvtvpWzpYRVSkCPezeiT5HtMOrXNwF/SQpw6amngd9k07stzKuaT A507eGyqZjvLGuaAMyT0zRf8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=1W6Pu+abY1YBJ574R2dIsLd7ekWj3ucuhC1D2H90J HA=; b=GY5/vI6WPvIIhuy+vVFw1Dxrx6f+x4hOE3wuT1gNjQhyigNk57y2nkoBD sC4hI5ojFhev5wbAJKuNp8hIP+dWfejBYPGoajljugPONo56INz+EBxm1/DGeXKK MBSOXJ3OTJVLjXxhHB87yga4j5LXZwe6z+4mcKrtD0mDoAa317GxZ7UELdrqXzN+ ufbmno6yO8q4Jq1jaxteRe9Fd/qWesceFQvIDoOwA/PVk19xFQkdqVCMuDTD688o DJ9GLs+KsSACvuyl2lqqs19J/IwOx0ikH5FIJRnz+xY+lRPXvg/hyGgwQ/Be4oFx JB+vYgL9o0Fh8hNDTtVF54KvpWz9w== X-ME-Sender: X-Sasl-enc: yAjROKa55XSwLPre5yogurrAtZv9+PbPV9XvVEViJeEz 1499204598 Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id CDB61240B0; Tue, 4 Jul 2017 17:43:17 -0400 (EDT) From: Thomas Monjalon To: gaetan.rivet@6wind.com Cc: dev@dpdk.org Date: Tue, 4 Jul 2017 23:43:13 +0200 Message-Id: <20170704214313.31828-1-thomas@monjalon.net> X-Mailer: git-send-email 2.13.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH] bus: fix driver registration 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: Tue, 04 Jul 2017 21:43:19 -0000 The bus name was stored with embedded double quotes. Indeed the bus name is given with a string in a macro, which is not used elsewhere. These macros are useless because the buses are drivers, so they must not have any API for the application writer. The registration can be done with a hardcoded value without quotes. There is another (small) benefit of not using macros for driver names: it is to have a meaningful constructor function name. For instance, it was businitfn_PCI_BUS_NAME instead of businitfn_pci. The bus registration macro is also changed to use the new RTE_INIT_PRIO macro, similar to RTE_INIT used for other drivers. The priority is the highest (101) in order to be sure that the bus driver is registered before its device drivers. Fixes: 0fd1a0eaae19 ("pci: add bus driver") Fixes: fea892e35f21 ("bus/vdev: use standard bus registration") Fixes: 7e7df6d0a41d ("bus/fslmc: introduce fsl-mc bus driver") Signed-off-by: Thomas Monjalon --- This patch is a proposal to replace the patch "bus: fix bus name registration" in the series "rte_bus parse API". --- drivers/bus/fslmc/fslmc_bus.c | 2 +- drivers/bus/fslmc/rte_fslmc.h | 3 --- lib/librte_eal/common/eal_common_pci.c | 2 +- lib/librte_eal/common/eal_common_vdev.c | 2 +- lib/librte_eal/common/include/rte_bus.h | 3 ++- lib/librte_eal/common/include/rte_eal.h | 3 +++ lib/librte_eal/common/include/rte_pci.h | 3 --- lib/librte_eal/common/include/rte_vdev.h | 2 -- 8 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index 1e3bbeeb0..f9e22111d 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -161,4 +161,4 @@ struct rte_fslmc_bus rte_fslmc_bus = { .driver_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.driver_list), }; -RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus); +RTE_REGISTER_BUS(fslmc, rte_fslmc_bus.bus); diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h index 040ab9588..8f3527815 100644 --- a/drivers/bus/fslmc/rte_fslmc.h +++ b/drivers/bus/fslmc/rte_fslmc.h @@ -56,9 +56,6 @@ extern "C" { #include #include -/** Name of FSLMC Bus */ -#define FSLMC_BUS_NAME "FSLMC" - struct rte_dpaa2_driver; /* DPAA2 Device and Driver lists for FSLMC bus */ diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 5ee100e67..2c99049a1 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -549,4 +549,4 @@ struct rte_pci_bus rte_pci_bus = { .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), }; -RTE_REGISTER_BUS(PCI_BUS_NAME, rte_pci_bus.bus); +RTE_REGISTER_BUS(pci, rte_pci_bus.bus); diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index baf3c5bfa..3bad0c463 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -374,4 +374,4 @@ static struct rte_bus rte_vdev_bus = { .unplug = vdev_unplug, }; -RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus); +RTE_REGISTER_BUS(vdev, rte_vdev_bus); diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 2f1c911f7..773b0d7af 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -256,7 +256,8 @@ struct rte_bus *rte_bus_find_by_name(const char *busname); * The constructor has higher priority than PMD constructors. */ #define RTE_REGISTER_BUS(nm, bus) \ -static void __attribute__((constructor(101), used)) businitfn_ ##nm(void) \ +RTE_INIT_PRIO(businitfn_ ##nm, 101); \ +static void businitfn_ ##nm(void) \ {\ (bus).name = RTE_STR(nm);\ rte_bus_register(&bus); \ diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index abf020bf9..6b7c5ca92 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -286,6 +286,9 @@ static inline int rte_gettid(void) #define RTE_INIT(func) \ static void __attribute__((constructor, used)) func(void) +#define RTE_INIT_PRIO(func, prio) \ +static void __attribute__((constructor(prio), used)) func(void) + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 0284a6208..7863f9457 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -77,9 +77,6 @@ const char *pci_get_sysfs_path(void); /** Maximum number of PCI resources. */ #define PCI_MAX_RESOURCE 6 -/** Name of PCI Bus */ -#define PCI_BUS_NAME "PCI" - /* Forward declarations */ struct rte_pci_device; struct rte_pci_driver; diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 2d02c68d7..e6b678ea3 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -41,8 +41,6 @@ extern "C" { #include #include -#define VIRTUAL_BUS_NAME "virtual" - struct rte_vdev_device { TAILQ_ENTRY(rte_vdev_device) next; /**< Next attached vdev */ struct rte_device device; /**< Inherit core device */ -- 2.13.1