From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: [PATCH v3 08/25] pci: Add pci_dev_exists() Date: Mon, 14 Nov 2016 17:19:04 -0500 Message-ID: <1479161961-20304-9-git-send-email-peterx@redhat.com> References: <1479161961-20304-1-git-send-email-peterx@redhat.com> Cc: drjones@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, rkrcmar@redhat.com, pbonzini@redhat.com, peterx@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55120 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964915AbcKNWTd (ORCPT ); Mon, 14 Nov 2016 17:19:33 -0500 In-Reply-To: <1479161961-20304-1-git-send-email-peterx@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Alexander Gordeev Cc: Thomas Huth Cc: Andrew Jones Cc: Peter Xu Reviewed-by: Andrew Jones Signed-off-by: Alexander Gordeev --- lib/pci.c | 6 ++++++ lib/pci.h | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/pci.c b/lib/pci.c index 74936f3..42f47d9 100644 --- a/lib/pci.c +++ b/lib/pci.c @@ -7,6 +7,12 @@ #include "pci.h" #include "asm/pci.h" +bool pci_dev_exists(pcidevaddr_t dev) +{ + return (pci_config_readw(dev, PCI_VENDOR_ID) != 0xffff && + pci_config_readw(dev, PCI_DEVICE_ID) != 0xffff); +} + /* Scan bus look for a specific device. Only bus 0 scanned for now. */ pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id) { diff --git a/lib/pci.h b/lib/pci.h index 1c20308..1462aa2 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -15,6 +15,7 @@ enum { PCIDEVADDR_INVALID = 0xffff, }; +extern bool pci_dev_exists(pcidevaddr_t dev); extern pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id); /* -- 2.7.4