From patchwork Wed Aug 17 12:07:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 9285749 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 0C231600CB for ; Wed, 17 Aug 2016 12:08:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 073EE29089 for ; Wed, 17 Aug 2016 12:08:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F03DD2908C; Wed, 17 Aug 2016 12:08:03 +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 2745F2908D for ; Wed, 17 Aug 2016 12:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753590AbcHQMH6 (ORCPT ); Wed, 17 Aug 2016 08:07:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34882 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753167AbcHQMH4 (ORCPT ); Wed, 17 Aug 2016 08:07:56 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 D800A85376 for ; Wed, 17 Aug 2016 12:07:55 +0000 (UTC) Received: from dhcp-27-118.brq.redhat.com (dhcp-27-122.brq.redhat.com [10.34.27.122]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7HC7i9q028577; Wed, 17 Aug 2016 08:07:54 -0400 From: Alexander Gordeev To: kvm@vger.kernel.org Cc: Alexander Gordeev , Thomas Huth , Andrew Jones Subject: [kvm-unit-tests PATCH v7 08/13] pci: Add pci_dev_exists() Date: Wed, 17 Aug 2016 14:07:09 +0200 Message-Id: <01567cb1d1635cc6cb7d853d2c79f38267f88afe.1471434672.git.agordeev@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Aug 2016 12:07:55 +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 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 7650da9ffaf2..8dea915662d5 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 1c20308c9344..1462aa2f0e1a 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); /*