From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Blunck Subject: [PATCH v7 09/15] bus: add rte_bus_find_by_name Date: Thu, 29 Jun 2017 20:22:00 +0200 Message-ID: <20170629182206.1072-10-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com To: dev@dpdk.org Return-path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id CB75058EC for ; Thu, 29 Jun 2017 20:22:37 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id u23so4075954wma.2 for ; Thu, 29 Jun 2017 11:22:37 -0700 (PDT) In-Reply-To: <20170629182206.1072-1-jblunck@infradead.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_bus.c | 14 ++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index d0e652e..418804a 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -203,3 +203,17 @@ rte_bus_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, } return dev; } + +static int +cmp_bus_name(const struct rte_bus *bus, const void *_name) +{ + const char *name = _name; + + return strcmp(bus->name, name); +} + +struct rte_bus * +rte_bus_find_by_name(const char *busname) +{ + return rte_bus_find(NULL, cmp_bus_name, (const void *)busname); +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index fea0f39..08f8d46 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -241,6 +241,11 @@ struct rte_device *rte_bus_find_device(const struct rte_device *start, struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); /** + * Find the registered bus for a given name. + */ +struct rte_bus *rte_bus_find_by_name(const char *busname); + +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors. */ -- 2.9.4