mirror of https://github.com/proxmox/mirror_qemu
hw/pci: made pci_bus_num a PCIBusClass method
Refactoring it as a method of PCIBusClass will allow different implementations for subclasses. Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Laszlo Ersek <lersek@redhat.com>master
parent
ce6a28ee05
commit
602141d997
13
hw/pci/pci.c
13
hw/pci/pci.c
|
@ -93,6 +93,14 @@ static bool pcibus_is_root(PCIBus *bus)
|
||||||
return !bus->parent_dev;
|
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)
|
static void pci_bus_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
BusClass *k = BUS_CLASS(klass);
|
BusClass *k = BUS_CLASS(klass);
|
||||||
|
@ -106,6 +114,7 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
|
||||||
k->reset = pcibus_reset;
|
k->reset = pcibus_reset;
|
||||||
|
|
||||||
pbc->is_root = pcibus_is_root;
|
pbc->is_root = pcibus_is_root;
|
||||||
|
pbc->bus_num = pcibus_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo pci_bus_info = {
|
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)
|
int pci_bus_num(PCIBus *s)
|
||||||
{
|
{
|
||||||
if (pci_bus_is_root(s))
|
return PCI_BUS_GET_CLASS(s)->bus_num(s);
|
||||||
return 0; /* pci host bridge */
|
|
||||||
return s->parent_dev->config[PCI_SECONDARY_BUS];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
|
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
|
||||||
|
|
|
@ -14,6 +14,7 @@ typedef struct PCIBusClass {
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
|
|
||||||
bool (*is_root)(PCIBus *bus);
|
bool (*is_root)(PCIBus *bus);
|
||||||
|
int (*bus_num)(PCIBus *bus);
|
||||||
} PCIBusClass;
|
} PCIBusClass;
|
||||||
|
|
||||||
struct PCIBus {
|
struct PCIBus {
|
||||||
|
|
Loading…
Reference in New Issue