From patchwork Tue Dec 9 03:42:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1847 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 06C998099; Tue, 9 Dec 2014 04:44:06 +0100 (CET) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by dpdk.org (Postfix) with ESMTP id 809508096 for ; Tue, 9 Dec 2014 04:44:04 +0100 (CET) Received: by mail-pa0-f43.google.com with SMTP id kx10so6528598pab.16 for ; Mon, 08 Dec 2014 19:44:03 -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=Gkg7gyISbtcWhkRSExYdxIVGLcY3SA6JnMXpzi6s1+dgjuk0agbB2SXmaQbTSupofD mh/GDbPI7TjH86gq2b5KBcdYcFCCHJjzCauruJnZmQLKJWZPRcth8OLp/AoYcI0b1heS lNL+m/6lCWofJV/7NP12Ug/d2DTEoFtg7cpfW+O6AVi1A80F1b/4sHxuND/MwkKYKRt4 nizVmjkNc9ZvUQtsZXwYtvYwg3dLFPJTfOlR9Zr+4YVJgs5faRN/GRooyY0KQUiovUq3 F1B6iT9EGpWgJmp7niOeAj9CG7Q78PhCxTjea9kRwgFEOyOonxPaTvoebI1iKPlA1Y1g IGFw== X-Gm-Message-State: ALoCoQmexEaAxxAFt6XX8c7w9j3OEQ6h4zBJuIMnwUgH8Q4Eym8+19ncNWFPM7KYYJrm2sXB4d/k X-Received: by 10.68.97.131 with SMTP id ea3mr1375148pbb.144.1418096643700; Mon, 08 Dec 2014 19:44:03 -0800 (PST) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id xx2sm2185pab.17.2014.12.08.19.44.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 19:44:03 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 9 Dec 2014 12:42:44 +0900 Message-Id: <1418096571-27531-22-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418096571-27531-1-git-send-email-mukawa@igel.co.jp> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418096571-27531-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 v2 21/28] 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.