Patchwork [RFC,25/34] vmmouse: QOM'ify

login
register
mail settings
Submitter Andreas Färber
Date Nov. 26, 2012, 12:12 a.m.
Message ID <1353888766-6951-26-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/201595/
State New
Headers show

Comments

Andreas Färber - Nov. 26, 2012, 12:12 a.m.
Introduce type constant and cast macro to obsolete DO_UPCAST() and
container_of(). Prepares for ISA realizefn.

Remove reserved underscore from struct name while at it.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/vmmouse.c |   16 ++++++++++------
 1 Datei geändert, 10 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

Patch

diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index 6338efa..7c7c4e4 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -51,9 +51,13 @@ 
 #define DPRINTF(fmt, ...) do { } while (0)
 #endif
 
-typedef struct _VMMouseState
+#define TYPE_VMMOUSE "vmmouse"
+#define VMMOUSE(obj) OBJECT_CHECK(VMMouseState, (obj), TYPE_VMMOUSE)
+
+typedef struct VMMouseState
 {
-    ISADevice dev;
+    ISADevice parent_obj;
+
     uint32_t queue[VMMOUSE_QUEUE_SIZE];
     int32_t queue_size;
     uint16_t nb_queue;
@@ -250,7 +254,7 @@  static const VMStateDescription vmstate_vmmouse = {
 
 static void vmmouse_reset(DeviceState *d)
 {
-    VMMouseState *s = container_of(d, VMMouseState, dev.qdev);
+    VMMouseState *s = VMMOUSE(d);
 
     s->status = 0xffff;
     s->queue_size = VMMOUSE_QUEUE_SIZE;
@@ -260,7 +264,7 @@  static void vmmouse_reset(DeviceState *d)
 
 static int vmmouse_initfn(ISADevice *dev)
 {
-    VMMouseState *s = DO_UPCAST(VMMouseState, dev, dev);
+    VMMouseState *s = VMMOUSE(dev);
 
     DPRINTF("vmmouse_init\n");
 
@@ -287,8 +291,8 @@  static void vmmouse_class_initfn(ObjectClass *klass, void *data)
     dc->props = vmmouse_properties;
 }
 
-static TypeInfo vmmouse_info = {
-    .name          = "vmmouse",
+static const TypeInfo vmmouse_info = {
+    .name          = TYPE_VMMOUSE,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(VMMouseState),
     .class_init    = vmmouse_class_initfn,