From patchwork Mon Feb 27 14:12:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 9593227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E289604AB for ; Mon, 27 Feb 2017 14:14:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 919FF2793B for ; Mon, 27 Feb 2017 14:14:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 862F62818B; Mon, 27 Feb 2017 14:14:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 326212793B for ; Mon, 27 Feb 2017 14:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751461AbdB0OOB (ORCPT ); Mon, 27 Feb 2017 09:14:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33424 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751398AbdB0ON4 (ORCPT ); Mon, 27 Feb 2017 09:13:56 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FFF64E4F2 for ; Mon, 27 Feb 2017 14:12:48 +0000 (UTC) Received: from dhcp-27-118.brq.redhat.com (dhcp-27-122.brq.redhat.com [10.34.27.122]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RECeej009330; Mon, 27 Feb 2017 09:12:47 -0500 From: Alexander Gordeev To: kvm@vger.kernel.org Cc: Alexander Gordeev , Thomas Huth , Andrew Jones Subject: [kvm-unit-tests PATCH v3 5/6] pci: Rework pci_bar_is_valid() Date: Mon, 27 Feb 2017 15:12:36 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 27 Feb 2017 14:12:48 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Thomas Huth Cc: Andrew Jones Signed-off-by: Alexander Gordeev --- lib/pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pci.c b/lib/pci.c index aded1b1ddb77..d9e3dfaa3726 100644 --- a/lib/pci.c +++ b/lib/pci.c @@ -206,7 +206,7 @@ bool pci_bar_is_memory(struct pci_dev *dev, int bar_num) bool pci_bar_is_valid(struct pci_dev *dev, int bar_num) { - return pci_bar_get(dev, bar_num); + return dev->resource[bar_num] != INVALID_PHYS_ADDR; } bool pci_bar_is64(struct pci_dev *dev, int bar_num) @@ -225,11 +225,11 @@ void pci_bar_print(struct pci_dev *dev, int bar_num) phys_addr_t size, start, end; uint32_t bar; - size = pci_bar_size(dev, bar_num); - if (!size) + if (!pci_bar_is_valid(dev, bar_num)) return; bar = pci_bar_get(dev, bar_num); + size = pci_bar_size(dev, bar_num); start = pci_bar_get_addr(dev, bar_num); end = start + size - 1; @@ -309,7 +309,7 @@ void pci_dev_print(pcidevaddr_t dev) return; for (i = 0; i < PCI_BAR_NUM; i++) { - if (pci_bar_size(&pci_dev, i)) { + if (pci_bar_is_valid(&pci_dev, i)) { printf("\t"); pci_bar_print(&pci_dev, i); printf("\n");