From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gaetan Rivet Subject: [PATCH v3] pci: implement find_device bus operation Date: Thu, 8 Jun 2017 01:54:48 +0200 Message-ID: <29efa24a4f059c8ec7cf54297ef8ace7f8d5ef13.1496876748.git.gaetan.rivet@6wind.com> References: <9d79d06e063c1337233dac6ab978bb98f52f6375.1496309620.git.gaetan.rivet@6wind.com> Cc: Gaetan Rivet To: dev@dpdk.org Return-path: Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id A1B702BBD for ; Thu, 8 Jun 2017 01:54:59 +0200 (CEST) Received: by mail-wr0-f173.google.com with SMTP id g76so11973682wrd.1 for ; Wed, 07 Jun 2017 16:54:59 -0700 (PDT) In-Reply-To: <9d79d06e063c1337233dac6ab978bb98f52f6375.1496309620.git.gaetan.rivet@6wind.com> 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: Gaetan Rivet --- This patch depends on: bus: attach / detach API http://dpdk.org/ml/archives/dev/2017-May/066330.html http://dpdk.org/dev/patchwork/patch/24489/ v1 --> v2 * Use the newly defined rte_dev_match_t type v2 --> v3 * Use new comparison behavior. --- lib/librte_eal/common/eal_common_pci.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 5ae5201..5a8478c 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -483,10 +483,23 @@ rte_pci_remove_device(struct rte_pci_device *pci_dev) TAILQ_REMOVE(&rte_pci_bus.device_list, pci_dev, next); } +static struct rte_device * +pci_find_device(rte_dev_cmp_t cmp, const void *data) +{ + struct rte_pci_device *dev; + + FOREACH_DEVICE_ON_PCIBUS(dev) { + if (cmp(&dev->device, data) == 0) + return &dev->device; + } + return NULL; +} + struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan, .probe = rte_pci_probe, + .find_device = pci_find_device, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), -- 2.1.4