Skip to contentSkip to conversation

ppc: QOM cast cleanups

PATCH New Andreas Färber 1 participant 2 messages Jul 27, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: QOM cast cleanups

Hello,

This series eliminates FROM_SYSBUS() in hw/ppc/.

Regards,
Andreas

Cc Hu Tao <[email protected]>

Andreas Färber (1):
ppce500_spin: QOM cast cleanup

 hw/ppc/ppce500_spin.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/1 ppce500_spin: QOM cast cleanup

Introduce type constant and use QOM cast.

---
 hw/ppc/ppce500_spin.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
hw/ppc/ppce500_spin.c +8 -6
index 11b7de2..78b23fa 100644
@@ -42,8 +42,12 @@ typedef struct spin_info {
     uint64_t reserved;
 } QEMU_PACKED SpinInfo;
 
-typedef struct spin_state {
-    SysBusDevice busdev;
+#define TYPE_E500_SPIN "e500-spin"
+#define E500_SPIN(obj) OBJECT_CHECK(SpinState, (obj), TYPE_E500_SPIN)
+
+typedef struct SpinState {
+    SysBusDevice parent_obj;
+
     MemoryRegion iomem;
     SpinInfo spin[MAX_CPUS];
 } SpinState;
@@ -187,9 +191,7 @@ static const MemoryRegionOps spin_rw_ops = {
 
 static int ppce500_spin_initfn(SysBusDevice *dev)
 {
-    SpinState *s;
-
-    s = FROM_SYSBUS(SpinState, SYS_BUS_DEVICE(dev));
+    SpinState *s = E500_SPIN(dev);
 
     memory_region_init_io(&s->iomem, OBJECT(s), &spin_rw_ops, s,
                           "e500 spin pv device", sizeof(SpinInfo) * MAX_CPUS);
@@ -208,7 +210,7 @@ static void ppce500_spin_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo ppce500_spin_info = {
-    .name          = "e500-spin",
+    .name          = TYPE_E500_SPIN,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(SpinState),
     .class_init    = ppce500_spin_class_init,
Signature · 1 line
1.8.1.4