[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/28] hw/pci: made pci_bus_num a PCIBusClass method
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 09/28] hw/pci: made pci_bus_num a PCIBusClass method |
Date: |
Thu, 4 Jun 2015 13:10:38 +0200 |
From: Marcel Apfelbaum <address@hidden>
Refactoring it as a method of PCIBusClass will allow
different implementations for subclasses.
Signed-off-by: Marcel Apfelbaum <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Acked-by: Laszlo Ersek <address@hidden>
---
include/hw/pci/pci_bus.h | 1 +
hw/pci/pci.c | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index b5ba9c4..7b9939e 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -14,6 +14,7 @@ typedef struct PCIBusClass {
/*< public >*/
bool (*is_root)(PCIBus *bus);
+ int (*bus_num)(PCIBus *bus);
} PCIBusClass;
struct PCIBus {
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 132d19e..2f24f74 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -93,6 +93,14 @@ static bool pcibus_is_root(PCIBus *bus)
return !bus->parent_dev;
}
+static int pcibus_num(PCIBus *bus)
+{
+ if (pcibus_is_root(bus)) {
+ return 0; /* pci host bridge */
+ }
+ return bus->parent_dev->config[PCI_SECONDARY_BUS];
+}
+
static void pci_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *k = BUS_CLASS(klass);
@@ -106,6 +114,7 @@ static void pci_bus_class_init(ObjectClass *klass, void
*data)
k->reset = pcibus_reset;
pbc->is_root = pcibus_is_root;
+ pbc->bus_num = pcibus_num;
}
static const TypeInfo pci_bus_info = {
@@ -390,9 +399,7 @@ PCIBus *pci_register_bus(DeviceState *parent, const char
*name,
int pci_bus_num(PCIBus *s)
{
- if (pci_bus_is_root(s))
- return 0; /* pci host bridge */
- return s->parent_dev->config[PCI_SECONDARY_BUS];
+ return PCI_BUS_GET_CLASS(s)->bus_num(s);
}
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
--
MST
- [Qemu-devel] [PULL 00/28] pc, acpi, virtio, tpm, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 01/28] acpi: add missing ssdt, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 02/28] hw/q35: fix floppy controller definition in ich9, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 03/28] virtio-pci: don't try to mask or unmask vqs without notifiers, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 04/28] TPM: fix build with tpm disabled, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 05/28] virtio: 64bit features fixups., Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 06/28] acpi: add acpi_send_gpe_event() to rise sci for hotplug, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 07/28] acpi: add implementation of aml_while() term, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 08/28] hw/pci: made pci_bus_is_root a PCIBusClass method, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 09/28] hw/pci: made pci_bus_num a PCIBusClass method,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 10/28] hw/i386: query only for q35/pc when looking for pci host bridge, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 11/28] hw/pci: extend PCI config access to support devices behind PXB, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 12/28] hw/acpi: add support for i440fx 'snooping' root busses, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 13/28] hw/apci: add _PRT method for extra PCI root busses, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 14/28] hw/acpi: add _CRS method for extra root busses, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 15/28] hw/acpi: remove from root bus 0 the crs resources used by other buses., Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 16/28] hw/pci: removed 'rootbus nr is 0' assumption from qmp_pci_query, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 17/28] hw/pci: introduce PCI Expander Bridge (PXB), Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 18/28] hw/pci: inform bios if the system has extra pci root buses, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 19/28] hw/pxb: add map_irq func, Michael S. Tsirkin, 2015/06/04