All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Gordeev <agordeev@redhat.com>
To: kvm@vger.kernel.org
Cc: Alexander Gordeev <agordeev@redhat.com>,
	Thomas Huth <thuth@redhat.com>, Andrew Jones <drjones@redhat.com>,
	Peter Xu <peterx@redhat.com>
Subject: [kvm-unit-tests PATCH v4 4/5] pci: Rework pci_bar_is_valid()
Date: Tue, 28 Feb 2017 19:08:29 +0100	[thread overview]
Message-ID: <440077a99c08e1d8300fecbaee0b2215c5b27ada.1488304691.git.agordeev@redhat.com> (raw)
In-Reply-To: <cover.1488304691.git.agordeev@redhat.com>
In-Reply-To: <cover.1488304691.git.agordeev@redhat.com>

Cc: Thomas Huth <thuth@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 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

  parent reply	other threads:[~2017-02-28 18:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-28 18:08 [kvm-unit-tests PATCH v4 0/5] pci: Complete conversion of PCI API to struct pci_dev Alexander Gordeev
2017-02-28 18:08 ` [kvm-unit-tests PATCH v4 1/5] pci: pci-host-generic: Use INVALID_PHYS_ADDR instead of ~0 Alexander Gordeev
2017-02-28 18:08 ` [kvm-unit-tests PATCH v4 2/5] pci: Accomodate 64 bit BARs in pci_dev::resource[] Alexander Gordeev
2017-02-28 18:08 ` [kvm-unit-tests PATCH v4 3/5] pci: Turn struct pci_dev into device handle for PCI functions Alexander Gordeev
2017-02-28 18:08 ` Alexander Gordeev [this message]
2017-02-28 18:08 ` [kvm-unit-tests PATCH v4 5/5] pci: Make PCI API consistent wrt using struct pci_dev Alexander Gordeev
2017-03-02 21:24 ` [kvm-unit-tests PATCH v4 0/5] pci: Complete conversion of PCI API to " Radim Krčmář
2017-03-06 20:06 ` [kvm-unit-tests PATCH v4 6/5] pci: Add BAR sanity checks Alexander Gordeev
2017-03-07 14:22   ` Andrew Jones
2017-03-07 19:39     ` Alexander Gordeev
2017-03-08 10:10       ` Andrew Jones
2017-03-08 11:40         ` Alexander Gordeev
2017-03-08 11:45           ` Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=440077a99c08e1d8300fecbaee0b2215c5b27ada.1488304691.git.agordeev@redhat.com \
    --to=agordeev@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=peterx@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.