From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Gordeev Subject: [kvm-unit-tests PATCH v4 4/5] pci: Rework pci_bar_is_valid() Date: Tue, 28 Feb 2017 19:08:29 +0100 Message-ID: <440077a99c08e1d8300fecbaee0b2215c5b27ada.1488304691.git.agordeev@redhat.com> References: Cc: Alexander Gordeev , Thomas Huth , Andrew Jones , Peter Xu To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50522 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751356AbdB1SI4 (ORCPT ); Tue, 28 Feb 2017 13:08:56 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 A03834E33B for ; Tue, 28 Feb 2017 18:08:40 +0000 (UTC) In-Reply-To: In-Reply-To: References: Sender: kvm-owner@vger.kernel.org List-ID: Cc: Thomas Huth Cc: Andrew Jones Cc: Peter Xu Reviewed-by: 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 cf33b894759d..fc18b254366c 100644 --- a/lib/pci.c +++ b/lib/pci.c @@ -205,7 +205,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) @@ -224,11 +224,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; @@ -308,7 +308,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"); -- 1.8.3.1