From patchwork Thu Nov 20 09:06:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1384 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1542A8053; Thu, 20 Nov 2014 09:57:49 +0100 (CET) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by dpdk.org (Postfix) with ESMTP id 88E458037 for ; Thu, 20 Nov 2014 09:57:41 +0100 (CET) Received: by mail-pd0-f170.google.com with SMTP id fp1so2723335pdb.1 for ; Thu, 20 Nov 2014 01:08:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+xIK2XzZo5dGkkQE9LtGoiGlJl84rmcmYxFgGMCOK58=; b=DZqfZSUBz3kKsJJ4q5ovBowiACcz38cX5PlwQCFxRwwTFYn7TkoYJuqsWMykqo9fPJ /6NoWgwk3V11UreuTV63rBJ+ZawuFkBDwFEmvO9bj5p18a82a05/aHpS5enHtKF6a8QL wKC/U0bvu+LyxaWjOnCXkHDHBSpYhZNEtTHWSMaXRtLJMoxPot+uTNvOvQK06vdjEsdl NaJHueGq97uvM3RjOzpd96E5Cu4zLtCbJlgdBh6fpsO9bHpUHaLENWTHj7Gs+nZ2Evw9 idcp4C32vIv1oAU0JgoMwm5ehXAiJC0yh+R0qOkd/yoRP2HIx50V8l4KV2s1loLGk1c7 9P1w== X-Gm-Message-State: ALoCoQmSJ1hZzkhNyFJM0bhitx/xpavHboUk3SSQi8QE/9LmGbIMyQbQOyCd9tWQKN2yr8fMiamr X-Received: by 10.69.18.225 with SMTP id gp1mr27833933pbd.144.1416474490361; Thu, 20 Nov 2014 01:08:10 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id a6sm1432407pbu.64.2014.11.20.01.08.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 01:08:09 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 20 Nov 2014 18:06:35 +0900 Message-Id: <1416474399-16851-22-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [PATCH 21/25] eal/pci: Fix pci_probe_all_drivers to share code with closing function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" pci_close_all_drivers() will be implemented after the patch. To share a part of code between thses 2 functions, The patch fixes pci_probe_all_drivers() first. Signed-off-by: Tetsuya Mukawa --- lib/librte_eal/common/eal_common_pci.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index f01f258..1e3efea 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -99,19 +99,20 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev) return NULL; } -/* - * If vendor/device ID match, call the devinit() function of all - * registered driver for the given device. Return -1 if initialization - * failed, return 1 if no driver is found for this device. - */ +#define INVOKE_PROBE (0) + static int -pci_probe_all_drivers(struct rte_pci_device *dev) +pci_invoke_all_drivers(struct rte_pci_device *dev, int type) { struct rte_pci_driver *dr = NULL; - int rc; + int rc = 0; TAILQ_FOREACH(dr, &pci_driver_list, next) { - rc = rte_eal_pci_probe_one_driver(dr, dev); + switch (type) { + case INVOKE_PROBE: + rc = rte_eal_pci_probe_one_driver(dr, dev); + break; + } if (rc < 0) /* negative value is an error */ return -1; @@ -124,6 +125,17 @@ pci_probe_all_drivers(struct rte_pci_device *dev) } /* + * If vendor/device ID match, call the devinit() function of all + * registered driver for the given device. Return -1 if initialization + * failed, return 1 if no driver is found for this device. + */ +static int +pci_probe_all_drivers(struct rte_pci_device *dev) +{ + return pci_invoke_all_drivers(dev, INVOKE_PROBE); +} + +/* * Scan the content of the PCI bus, and call the devinit() function for * all registered drivers that have a matching entry in its id_table * for discovered devices.