From patchwork Thu Jan 27 06:56:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 80605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D5782B70EA for ; Thu, 27 Jan 2011 18:06:53 +1100 (EST) Received: from localhost ([127.0.0.1]:37763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiLwQ-000637-Qz for incoming@patchwork.ozlabs.org; Thu, 27 Jan 2011 02:06:50 -0500 Received: from [140.186.70.92] (port=44806 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiLmh-00005s-A8 for qemu-devel@nongnu.org; Thu, 27 Jan 2011 01:56:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PiLmg-0003QV-4h for qemu-devel@nongnu.org; Thu, 27 Jan 2011 01:56:47 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]:37202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PiLmf-0003QA-Ef for qemu-devel@nongnu.org; Thu, 27 Jan 2011 01:56:46 -0500 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 4B26287485; Thu, 27 Jan 2011 15:56:41 +0900 (JST) Received: (nullmailer pid 32106 invoked by uid 1000); Thu, 27 Jan 2011 06:56:39 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Thu, 27 Jan 2011 15:56:36 +0900 Message-Id: <497009684f40e87fab31b3281a78f11cf5aa7e1f.1296111201.git.yamahata@valinux.co.jp> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 2/5] pci: use devfn for pci_find_device() instead of (slot, fn) pair X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org (slot, fn) pair is somewhat confusing because of ARI. So use devfn for pci_find_device() instead of (slot, fn). Signed-off-by: Isaku Yamahata --- hw/pci-hotplug.c | 5 +++-- hw/pci.c | 4 ++-- hw/pci.h | 2 +- hw/pci_host.c | 2 +- hw/pcie_host.c | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 270a982..9715235 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -126,7 +126,8 @@ void drive_hot_add(Monitor *mon, const QDict *qdict) if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } - dev = pci_find_device(pci_find_root_bus(dom), pci_bus, slot, 0); + dev = pci_find_device(pci_find_root_bus(dom), pci_bus, + PCI_DEVFN(slot, 0)); if (!dev) { monitor_printf(mon, "no pci device with address %s\n", pci_addr); goto err; @@ -276,7 +277,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr) return -1; } - d = pci_find_device(pci_find_root_bus(dom), bus, slot, 0); + d = pci_find_device(pci_find_root_bus(dom), bus, PCI_DEVFN(slot, 0)); if (!d) { monitor_printf(mon, "slot %d empty\n", slot); return -1; diff --git a/hw/pci.c b/hw/pci.c index 9085680..899b23d 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1602,14 +1602,14 @@ PCIBus *pci_find_bus(PCIBus *bus, int bus_num) return NULL; } -PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function) +PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn) { bus = pci_find_bus(bus, bus_num); if (!bus) return NULL; - return bus->devices[PCI_DEVFN(slot, function)]; + return bus->devices[devfn]; } static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) diff --git a/hw/pci.h b/hw/pci.h index aa5f912..72025b1 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -252,7 +252,7 @@ void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDe PCIBus *pci_find_root_bus(int domain); int pci_find_domain(const PCIBus *bus); PCIBus *pci_find_bus(PCIBus *bus, int bus_num); -PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function); +PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn); int pci_qdev_find_device(const char *id, PCIDevice **pdev); PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr); diff --git a/hw/pci_host.c b/hw/pci_host.c index 7c40155..728e2d4 100644 --- a/hw/pci_host.c +++ b/hw/pci_host.c @@ -44,7 +44,7 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr) uint8_t bus_num = addr >> 16; uint8_t devfn = addr >> 8; - return pci_find_device(bus, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn)); + return pci_find_device(bus, bus_num, devfn); } void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len) diff --git a/hw/pcie_host.c b/hw/pcie_host.c index 21069ee..b749865 100644 --- a/hw/pcie_host.c +++ b/hw/pcie_host.c @@ -49,8 +49,7 @@ static inline PCIDevice *pcie_dev_find_by_mmcfg_addr(PCIBus *s, uint32_t mmcfg_addr) { return pci_find_device(s, PCIE_MMCFG_BUS(mmcfg_addr), - PCI_SLOT(PCIE_MMCFG_DEVFN(mmcfg_addr)), - PCI_FUNC(PCIE_MMCFG_DEVFN(mmcfg_addr))); + PCIE_MMCFG_DEVFN(mmcfg_addr)); } static void pcie_mmcfg_data_write(PCIBus *s,