Message ID | 20191023173154.30051-21-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | Clean-ups: qom-ify serial and remove QDEV_PROP_PTR | expand |
On 10/23/19 7:31 PM, Marc-André Lureau wrote: > While at it, use the expected type. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > --- > hw/i386/pc.c | 6 +++--- > hw/i386/vmmouse.c | 8 +++----- > hw/input/pckbd.c | 8 +++----- > include/hw/input/i8042.h | 4 +++- > 4 files changed, 12 insertions(+), 14 deletions(-) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 00ee16ccab..021ec8c593 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1861,9 +1861,9 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) > vmmouse = NULL; > } > if (vmmouse) { > - DeviceState *dev = DEVICE(vmmouse); > - qdev_prop_set_ptr(dev, "ps2_mouse", i8042); > - qdev_init_nofail(dev); > + object_property_set_link(OBJECT(vmmouse), OBJECT(i8042), > + "i8042", &error_abort); > + qdev_init_nofail(DEVICE(vmmouse)); > } > port92 = isa_create_simple(isa_bus, "port92"); > > diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c > index 41ad91ad53..c0c329f817 100644 > --- a/hw/i386/vmmouse.c > +++ b/hw/i386/vmmouse.c > @@ -66,7 +66,7 @@ typedef struct VMMouseState > uint16_t status; > uint8_t absolute; > QEMUPutMouseEntry *entry; > - void *ps2_mouse; > + ISAKBDState *i8042; > } VMMouseState; > > static uint32_t vmmouse_get_status(VMMouseState *s) > @@ -105,7 +105,7 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_ > > /* need to still generate PS2 events to notify driver to > read from queue */ > - i8042_isa_mouse_fake_event(s->ps2_mouse); > + i8042_isa_mouse_fake_event(s->i8042); > } > > static void vmmouse_remove_handler(VMMouseState *s) > @@ -275,7 +275,7 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp) > } > > static Property vmmouse_properties[] = { > - DEFINE_PROP_PTR("ps2_mouse", VMMouseState, ps2_mouse), > + DEFINE_PROP_LINK("i8042", VMMouseState, i8042, TYPE_I8042, ISAKBDState *), > DEFINE_PROP_END_OF_LIST(), > }; > > @@ -287,8 +287,6 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data) > dc->reset = vmmouse_reset; > dc->vmsd = &vmstate_vmmouse; > dc->props = vmmouse_properties; > - /* Reason: pointer property "ps2_mouse" */ > - dc->user_creatable = false; > } > > static const TypeInfo vmmouse_info = { > diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c > index f0acfd86f7..9b641021c9 100644 > --- a/hw/input/pckbd.c > +++ b/hw/input/pckbd.c > @@ -483,17 +483,15 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, > > #define I8042(obj) OBJECT_CHECK(ISAKBDState, (obj), TYPE_I8042) > > -typedef struct ISAKBDState { > +struct ISAKBDState { > ISADevice parent_obj; > > KBDState kbd; > MemoryRegion io[2]; > -} ISAKBDState; > +}; > > -void i8042_isa_mouse_fake_event(void *opaque) > +void i8042_isa_mouse_fake_event(ISAKBDState *isa) > { > - ISADevice *dev = opaque; > - ISAKBDState *isa = I8042(dev); > KBDState *s = &isa->kbd; > > ps2_mouse_fake_event(s->mouse); > diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h > index 246e6f3335..8eaebf50ce 100644 > --- a/include/hw/input/i8042.h > +++ b/include/hw/input/i8042.h > @@ -14,10 +14,12 @@ > > #define I8042_A20_LINE "a20" > > +typedef struct ISAKBDState ISAKBDState; > + > void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, > MemoryRegion *region, ram_addr_t size, > hwaddr mask); > -void i8042_isa_mouse_fake_event(void *opaque); > +void i8042_isa_mouse_fake_event(ISAKBDState *isa); > void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out); > > #endif /* HW_INPUT_I8042_H */ > Nice! Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 00ee16ccab..021ec8c593 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1861,9 +1861,9 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) vmmouse = NULL; } if (vmmouse) { - DeviceState *dev = DEVICE(vmmouse); - qdev_prop_set_ptr(dev, "ps2_mouse", i8042); - qdev_init_nofail(dev); + object_property_set_link(OBJECT(vmmouse), OBJECT(i8042), + "i8042", &error_abort); + qdev_init_nofail(DEVICE(vmmouse)); } port92 = isa_create_simple(isa_bus, "port92"); diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 41ad91ad53..c0c329f817 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -66,7 +66,7 @@ typedef struct VMMouseState uint16_t status; uint8_t absolute; QEMUPutMouseEntry *entry; - void *ps2_mouse; + ISAKBDState *i8042; } VMMouseState; static uint32_t vmmouse_get_status(VMMouseState *s) @@ -105,7 +105,7 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_ /* need to still generate PS2 events to notify driver to read from queue */ - i8042_isa_mouse_fake_event(s->ps2_mouse); + i8042_isa_mouse_fake_event(s->i8042); } static void vmmouse_remove_handler(VMMouseState *s) @@ -275,7 +275,7 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp) } static Property vmmouse_properties[] = { - DEFINE_PROP_PTR("ps2_mouse", VMMouseState, ps2_mouse), + DEFINE_PROP_LINK("i8042", VMMouseState, i8042, TYPE_I8042, ISAKBDState *), DEFINE_PROP_END_OF_LIST(), }; @@ -287,8 +287,6 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data) dc->reset = vmmouse_reset; dc->vmsd = &vmstate_vmmouse; dc->props = vmmouse_properties; - /* Reason: pointer property "ps2_mouse" */ - dc->user_creatable = false; } static const TypeInfo vmmouse_info = { diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index f0acfd86f7..9b641021c9 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -483,17 +483,15 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, #define I8042(obj) OBJECT_CHECK(ISAKBDState, (obj), TYPE_I8042) -typedef struct ISAKBDState { +struct ISAKBDState { ISADevice parent_obj; KBDState kbd; MemoryRegion io[2]; -} ISAKBDState; +}; -void i8042_isa_mouse_fake_event(void *opaque) +void i8042_isa_mouse_fake_event(ISAKBDState *isa) { - ISADevice *dev = opaque; - ISAKBDState *isa = I8042(dev); KBDState *s = &isa->kbd; ps2_mouse_fake_event(s->mouse); diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index 246e6f3335..8eaebf50ce 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -14,10 +14,12 @@ #define I8042_A20_LINE "a20" +typedef struct ISAKBDState ISAKBDState; + void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, MemoryRegion *region, ram_addr_t size, hwaddr mask); -void i8042_isa_mouse_fake_event(void *opaque); +void i8042_isa_mouse_fake_event(ISAKBDState *isa); void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out); #endif /* HW_INPUT_I8042_H */