Re: [Qemu-devel] [PATCH v2 03/21] char/grlib_apbuart: Convert sysbus init function to realize function
On 23/11/18 16:30, Mao Zhongyi wrote: > Use DeviceClass rather than SysBusDeviceClass in > grlib_apbuart_class_init(). > > Cc: chout...@adacore.com > Cc: marcandre.lur...@redhat.com > Cc: pbonz...@redhat.com > > Signed-off-by: Mao Zhongyi > Signed-off-by: Zhang Shengju Reviewed-by: Philippe Mathieu-Daudé > --- > hw/char/grlib_apbuart.c | 12 +--- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c > index bac11bec58..e1d258b611 100644 > --- a/hw/char/grlib_apbuart.c > +++ b/hw/char/grlib_apbuart.c > @@ -239,9 +239,10 @@ static const MemoryRegionOps grlib_apbuart_ops = { > .endianness = DEVICE_NATIVE_ENDIAN, > }; > > -static int grlib_apbuart_init(SysBusDevice *dev) > +static void grlib_apbuart_realize(DeviceState *dev, Error **errp) > { > UART *uart = GRLIB_APB_UART(dev); > +SysBusDevice *sbd = SYS_BUS_DEVICE(dev); > > qemu_chr_fe_set_handlers(>chr, > grlib_apbuart_can_receive, > @@ -249,14 +250,12 @@ static int grlib_apbuart_init(SysBusDevice *dev) > grlib_apbuart_event, > NULL, uart, NULL, true); > > -sysbus_init_irq(dev, >irq); > +sysbus_init_irq(sbd, >irq); > > memory_region_init_io(>iomem, OBJECT(uart), _apbuart_ops, > uart, >"uart", UART_REG_SIZE); > > -sysbus_init_mmio(dev, >iomem); > - > -return 0; > +sysbus_init_mmio(sbd, >iomem); > } > > static void grlib_apbuart_reset(DeviceState *d) > @@ -280,9 +279,8 @@ static Property grlib_apbuart_properties[] = { > static void grlib_apbuart_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > -SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > > -k->init = grlib_apbuart_init; > +dc->realize = grlib_apbuart_realize; > dc->reset = grlib_apbuart_reset; > dc->props = grlib_apbuart_properties; > } >
[Qemu-devel] [PATCH v2 03/21] char/grlib_apbuart: Convert sysbus init function to realize function
Use DeviceClass rather than SysBusDeviceClass in grlib_apbuart_class_init(). Cc: chout...@adacore.com Cc: marcandre.lur...@redhat.com Cc: pbonz...@redhat.com Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju --- hw/char/grlib_apbuart.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c index bac11bec58..e1d258b611 100644 --- a/hw/char/grlib_apbuart.c +++ b/hw/char/grlib_apbuart.c @@ -239,9 +239,10 @@ static const MemoryRegionOps grlib_apbuart_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int grlib_apbuart_init(SysBusDevice *dev) +static void grlib_apbuart_realize(DeviceState *dev, Error **errp) { UART *uart = GRLIB_APB_UART(dev); +SysBusDevice *sbd = SYS_BUS_DEVICE(dev); qemu_chr_fe_set_handlers(>chr, grlib_apbuart_can_receive, @@ -249,14 +250,12 @@ static int grlib_apbuart_init(SysBusDevice *dev) grlib_apbuart_event, NULL, uart, NULL, true); -sysbus_init_irq(dev, >irq); +sysbus_init_irq(sbd, >irq); memory_region_init_io(>iomem, OBJECT(uart), _apbuart_ops, uart, "uart", UART_REG_SIZE); -sysbus_init_mmio(dev, >iomem); - -return 0; +sysbus_init_mmio(sbd, >iomem); } static void grlib_apbuart_reset(DeviceState *d) @@ -280,9 +279,8 @@ static Property grlib_apbuart_properties[] = { static void grlib_apbuart_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); -SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); -k->init = grlib_apbuart_init; +dc->realize = grlib_apbuart_realize; dc->reset = grlib_apbuart_reset; dc->props = grlib_apbuart_properties; } -- 2.17.1