From patchwork Thu Dec 11 02:20:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 419926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2C06A1400A0 for ; Thu, 11 Dec 2014 13:29:07 +1100 (AEDT) Received: from localhost ([::1]:48803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XytV3-0003Hd-Bw for incoming@patchwork.ozlabs.org; Wed, 10 Dec 2014 21:29:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XytQN-0005Er-Po for qemu-devel@nongnu.org; Wed, 10 Dec 2014 21:24:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XytQF-0004Zh-Tk for qemu-devel@nongnu.org; Wed, 10 Dec 2014 21:24:15 -0500 Received: from [59.151.112.132] (port=9841 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XytQF-0004YP-II for qemu-devel@nongnu.org; Wed, 10 Dec 2014 21:24:07 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="44842780" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Dec 2014 10:20:45 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id sBB2Nf0N025302; Thu, 11 Dec 2014 10:23:41 +0800 Received: from localhost.localdomain (10.167.226.102) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 11 Dec 2014 10:24:12 +0800 From: Hu Tao To: Date: Thu, 11 Dec 2014 10:20:28 +0800 Message-ID: <020963ffeebb642cd47ec5827bce95e9e14863d7.1418264106.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.102] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Marcel Apfelbaum , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v3 6/6] pci: introduce PCI_DEVFN_AUTO X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Introduce PCI_DEVFN_AUTO rather than using -1 in code. Signed-off-by: Hu Tao --- hw/core/qdev-properties.c | 1 + hw/pci/pci.c | 5 ++--- include/hw/pci/pci.h | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 2e47f70..df4ad14 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -6,6 +6,7 @@ #include "net/hub.h" #include "qapi/visitor.h" #include "sysemu/char.h" +#include "hw/pci/pci.h" void qdev_prop_set_after_realize(DeviceState *dev, const char *name, Error **errp) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 371699c..73c7dec 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -50,7 +50,7 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev); static void pcibus_reset(BusState *qbus); static Property pci_props[] = { - DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), + DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, PCI_DEVFN_AUTO), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, @@ -801,7 +801,6 @@ static void do_pci_unregister_device(PCIDevice *pci_dev) address_space_destroy(&pci_dev->bus_master_as); } -/* -1 for devfn means auto assign */ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn) { @@ -810,7 +809,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, PCIConfigWriteFunc *config_write = pc->config_write; AddressSpace *dma_as; - if (devfn < 0) { + if (devfn == PCI_DEVFN_AUTO) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn += PCI_FUNC_MAX) { if (!bus->devices[devfn]) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index b18759a..9206b12 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -164,6 +164,8 @@ enum { QEMU_PCIE_SLTCAP_PCP = (1 << QEMU_PCIE_SLTCAP_PCP_BITNR), }; +#define PCI_DEVFN_AUTO -1 + #define TYPE_PCI_DEVICE "pci-device" #define PCI_DEVICE(obj) \ OBJECT_CHECK(PCIDevice, (obj), TYPE_PCI_DEVICE)