From patchwork Tue Nov 4 03:45:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1107 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 972767FCC; Tue, 4 Nov 2014 04:37:42 +0100 (CET) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id 278DC7F6D for ; Tue, 4 Nov 2014 04:37:41 +0100 (CET) Received: by mail-pa0-f50.google.com with SMTP id eu11so13415146pac.23 for ; Mon, 03 Nov 2014 19:46:57 -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=IEKyy32GmmYFXUJqcHbecKlS+rl6xulh1kTaK1EvqTG0mrCN/xFLaEbbdO6hZopKh4 hTJzWyYcsZu3L1bwPfG7e7V+QskTCekVeA412Vk9QS6frAoQnJkaWCgxYrnfdt217Uti RUF5jn9X57oACibPEeDZixloXa9MhTe63cbi5ySKo6TTuaW6m23JY9ODl95R+vqvEe3f 3qfFErLlpE/fwnrICAHu/A93FmnFnrMU1RF7Mo0xsMD8CMpK7tQaozUlwkG+O5Kt4WLL iayA+XEnEwx52r1favdSKK56rG7OsP+sozyy2V0nRHP5qx7YFfT+ntsbYoJm/NfV0IJU q2Hw== X-Gm-Message-State: ALoCoQndmHIfreoiiHEwmhaZ4GGKGnP8Fyi4RwA5y/OIyEOOmU6VG9KoDF+/NHkaFLWo678zrHps X-Received: by 10.66.188.200 with SMTP id gc8mr47212206pac.38.1415072817336; Mon, 03 Nov 2014 19:46:57 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id jc3sm18430580pbb.49.2014.11.03.19.46.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Nov 2014 19:46:56 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 4 Nov 2014 12:45:41 +0900 Message-Id: <1415072748-31937-22-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415072748-31937-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> <1415072748-31937-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [RFC 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.