Patchwork [v2,10/12] isa: QOM'ify ISABus

login
register
mail settings
Submitter Andreas Färber
Date June 7, 2013, 12:58 p.m.
Message ID <1370609900-21998-11-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/249705/
State New
Headers show

Comments

Andreas Färber - June 7, 2013, 12:58 p.m.
Rename its parent field and use ISA_BUS() where necessary.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/isa/i82378.c      | 2 +-
 hw/isa/isa-bus.c     | 8 ++++----
 hw/isa/piix4.c       | 2 +-
 hw/isa/vt82c686.c    | 2 +-
 hw/ppc/prep.c        | 2 +-
 hw/sparc64/sun4u.c   | 3 +--
 include/hw/isa/isa.h | 5 ++++-
 7 files changed, 13 insertions(+), 11 deletions(-)

Patch

diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index cced9af..278e178 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -168,7 +168,7 @@  static void i82378_request_pic_irq(void *opaque, int irq, int level)
 
 static void i82378_init(DeviceState *dev, I82378State *s)
 {
-    ISABus *isabus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(dev, "isa.0"));
+    ISABus *isabus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
     ISADevice *pit;
     ISADevice *isa;
     qemu_irq *out0_irq;
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index f12b15d..7aa9b89 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -55,7 +55,7 @@  ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io)
         qdev_init_nofail(dev);
     }
 
-    isabus = FROM_QBUS(ISABus, qbus_create(TYPE_ISA_BUS, dev, NULL));
+    isabus = ISA_BUS(qbus_create(TYPE_ISA_BUS, dev, NULL));
     isabus->address_space_io = address_space_io;
     return isabus;
 }
@@ -76,7 +76,7 @@  void isa_bus_irqs(ISABus *bus, qemu_irq *irqs)
  */
 qemu_irq isa_get_irq(ISADevice *dev, int isairq)
 {
-    assert(!dev || DO_UPCAST(ISABus, qbus, dev->qdev.parent_bus) == isabus);
+    assert(!dev || ISA_BUS(qdev_get_parent_bus(DEVICE(dev))) == isabus);
     if (isairq < 0 || isairq > 15) {
         hw_error("isa irq %d invalid", isairq);
     }
@@ -135,7 +135,7 @@  ISADevice *isa_create(ISABus *bus, const char *name)
         hw_error("Tried to create isa device %s with no isa bus present.",
                  name);
     }
-    dev = qdev_create(&bus->qbus, name);
+    dev = qdev_create(BUS(bus), name);
     return ISA_DEVICE(dev);
 }
 
@@ -147,7 +147,7 @@  ISADevice *isa_try_create(ISABus *bus, const char *name)
         hw_error("Tried to create isa device %s with no isa bus present.",
                  name);
     }
-    dev = qdev_try_create(&bus->qbus, name);
+    dev = qdev_try_create(BUS(bus), name);
     return ISA_DEVICE(dev);
 }
 
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index d750413..1a1d451 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -98,7 +98,7 @@  int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)
     PCIDevice *d;
 
     d = pci_create_simple_multifunction(bus, devfn, true, "PIIX4");
-    *isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(&d->qdev, "isa.0"));
+    *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0"));
     return d->devfn;
 }
 
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 5261927..391d90d 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -450,7 +450,7 @@  ISABus *vt82c686b_init(PCIBus *bus, int devfn)
 
     d = pci_create_simple_multifunction(bus, devfn, true, "VT82C686B");
 
-    return DO_UPCAST(ISABus, qbus, qdev_get_child_bus(&d->qdev, "isa.0"));
+    return ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0"));
 }
 
 static void via_class_init(ObjectClass *klass, void *data)
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index be8a50e..9e770ab 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -601,7 +601,7 @@  static void ppc_prep_init(QEMUMachineInitArgs *args)
     sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11));
     sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9));
     sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11));
-    isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(&pci->qdev, "isa.0"));
+    isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), "isa.0"));
 
     /* Super I/O (parallel + serial ports) */
     isa = isa_create(isa_bus, TYPE_PC87312);
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 2c2a111..a6a3b76 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -585,8 +585,7 @@  pci_ebus_init(PCIBus *bus, int devfn, qemu_irq *irqs)
     ISABus *isa_bus;
 
     pci_dev = pci_create_simple(bus, devfn, "ebus");
-    isa_bus = DO_UPCAST(ISABus, qbus,
-                        qdev_get_child_bus(&pci_dev->qdev, "isa.0"));
+    isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci_dev), "isa.0"));
     isa_irq = qemu_allocate_irqs(isa_irq_handler, irqs, 16);
     isa_bus_irqs(isa_bus, isa_irq);
     return isa_bus;
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index 1f6ff55..da731d7 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -25,7 +25,10 @@  typedef struct ISADeviceClass {
 } ISADeviceClass;
 
 struct ISABus {
-    BusState qbus;
+    /*< private >*/
+    BusState parent_obj;
+    /*< public >*/
+
     MemoryRegion *address_space_io;
     qemu_irq *irqs;
 };