From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id 0CAB2B3D6 for ; Tue, 10 May 2016 20:15:56 +0200 (CEST) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3r46rC67c9z3qn; Tue, 10 May 2016 20:15:55 +0200 (CEST) From: Jan Viktorin To: dev@dpdk.org Cc: Jan Viktorin , Thomas Monjalon , David Marchand , Bruce Richardson Date: Tue, 10 May 2016 20:13:26 +0200 Message-Id: <1462904011-29838-7-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1462904011-29838-1-git-send-email-viktorin@rehivetech.com> References: <1462904011-29838-1-git-send-email-viktorin@rehivetech.com> In-Reply-To: <1461935496-20367-1-git-send-email-viktorin@rehivetech.com> References: <1461935496-20367-1-git-send-email-viktorin@rehivetech.com> Subject: [dpdk-dev] [PATCH v2 06/11] app/test: use linked list to store PCI drivers 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: , X-List-Received-Date: Tue, 10 May 2016 18:15:56 -0000 The test unregisters all real drivers before starting into an array. This inflexiable as we can use a linked list for this purpose. Signed-off-by: Jan Viktorin --- app/test/test_pci.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/test/test_pci.c b/app/test/test_pci.c index 0ed357e..cf82373 100644 --- a/app/test/test_pci.c +++ b/app/test/test_pci.c @@ -144,21 +144,24 @@ static void free_devargs_list(void) } } +/* real drivers (not used for testing) */ +struct pci_driver_list real_pci_driver_list = + TAILQ_HEAD_INITIALIZER(real_pci_driver_list); + int test_pci(void) { struct rte_devargs_list save_devargs_list; struct rte_pci_driver *dr = NULL; - struct rte_pci_driver *save_pci_driver_list[NUM_MAX_DRIVERS]; - unsigned i, num_drivers = 0; printf("Dump all devices\n"); rte_eal_pci_dump(stdout); /* Unregister all previous drivers */ - TAILQ_FOREACH(dr, &pci_driver_list, next) { + while (!TAILQ_EMPTY(&pci_driver_list)) { + dr = TAILQ_FIRST(&pci_driver_list); rte_eal_pci_unregister(dr); - save_pci_driver_list[num_drivers++] = dr; + TAILQ_INSERT_TAIL(&real_pci_driver_list, dr, next); } rte_eal_pci_register(&my_driver); @@ -197,8 +200,11 @@ test_pci(void) rte_eal_pci_unregister(&my_driver2); /* Restore original driver list */ - for (i = 0; i < num_drivers; i++) - rte_eal_pci_register(save_pci_driver_list[i]); + while (!TAILQ_EMPTY(&real_pci_driver_list)) { + dr = TAILQ_FIRST(&real_pci_driver_list); + TAILQ_REMOVE(&real_pci_driver_list, dr, next); + rte_eal_pci_register(dr); + } return 0; } -- 2.8.0