From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=qxaUWI9EmxD4gLjW6vo9nosNo0TSQBIovhDo3dV34x4=; b=l/G5cUVpl+N0sq76KUHNrmjG/lNM3UNfLgxPqSHqnVFw7wwdhUAOkb7hqKdfI2yVfg YEY87Z0IAIA251r5adQJPhmgOYk8BhjlEeiKF9s0ziih0uAyevlPbx8Ogji8EdP0fRTS M2FN2hfHwSdsOIT5mEYsM/LKs7KMELbGxnnKM/eFLoqLKw3I6LV9RX+hr8GfzY06H02z QVw+WWfVUmNHatSjcIjapr5xKsps2TqPdjg5s4HCuPxc04EntAPZMyDA/rSvHRhaoA+O 3OWch3WyPsQaSiad96Ei0DfYrWoUbQ/bHcUk8CmtP28IQ7U1HPOprishB0mAb7xRmnBi i8cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=qxaUWI9EmxD4gLjW6vo9nosNo0TSQBIovhDo3dV34x4=; b=OvkjJCbLQMwpRETZG2wZOR67vXOMypFEs/05HFv5GYUp2ZoT8vHtwK63pekWA7vxeY 5bYTyDj2G8fYC1sd2V12khmM+b6Esf3tm1wmofnFAyYS2W522MdkNrAGPW+8E2ppTdPQ HBv3M3tJvqlshBm7UZOFma/7L/2vt3akbacanBkinSJRdqYiu7bVDl030knq62NC4WCU O/+KOwKpDCmbONvHT05Bl5xQRjb0OpmtnKmL8JCd8TJe5BnbpbhUjIomuH/gz/+WQjCF F9aiA6BwW9pQ7usN4ge6w9gYPhIbht2C+DHNF2pcPD7AG936FThLuj0d9gY47zIPdg2t bfBA== X-Gm-Message-State: AKS2vOyL147T2MhHysS5wmO8DkZXCWTfB+NgfInrGmsX9SF+cO/z+0na 2sRYQxw46n5/KYVc X-Received: by 10.80.226.140 with SMTP id p12mr2074580edl.37.1498760557426; Thu, 29 Jun 2017 11:22:37 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id e28sm1446366ede.14.2017.06.29.11.22.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 11:22:36 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Thu, 29 Jun 2017 20:22:00 +0200 Message-Id: <20170629182206.1072-10-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170629182206.1072-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v7 09/15] bus: add rte_bus_find_by_name 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: Thu, 29 Jun 2017 18:22:38 -0000 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