[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [PATCH 2/2] hw/char: QOM'ify grlib_apbuart.c
From: |
Peter Maydell |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [PATCH 2/2] hw/char: QOM'ify grlib_apbuart.c |
Date: |
Thu, 5 Jan 2017 15:51:30 +0000 |
On 31 December 2016 at 01:18, xiaoqiang zhao <address@hidden> wrote:
> Drop the old Sysbus init and use instance_init and
> DeviceClass::realize instead
>
> Signed-off-by: xiaoqiang zhao <address@hidden>
> ---
> hw/char/grlib_apbuart.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c
> index db686e6a6f..620b801f34 100644
> --- a/hw/char/grlib_apbuart.c
> +++ b/hw/char/grlib_apbuart.c
> @@ -239,24 +239,28 @@ static const MemoryRegionOps grlib_apbuart_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static int grlib_apbuart_init(SysBusDevice *dev)
> +static void grlib_apbuart_init(Object *obj)
> {
> + SysBusDevice *dev = SYS_BUS_DEVICE(obj);
> UART *uart = GRLIB_APB_UART(dev);
>
> - qemu_chr_fe_set_handlers(&uart->chr,
> - grlib_apbuart_can_receive,
> - grlib_apbuart_receive,
> - grlib_apbuart_event,
> - uart, NULL, true);
> -
> sysbus_init_irq(dev, &uart->irq);
>
> - memory_region_init_io(&uart->iomem, OBJECT(uart), &grlib_apbuart_ops,
> uart,
> + memory_region_init_io(&uart->iomem, obj, &grlib_apbuart_ops, uart,
> "uart", UART_REG_SIZE);
>
> sysbus_init_mmio(dev, &uart->iomem);
> +}
>
> - return 0;
> +static void grlib_apbuart_realize(DeviceState *dev, Error **errp)
> +{
> + UART *uart = GRLIB_APB_UART(dev);
> +
> + qemu_chr_fe_set_handlers(&uart->chr,
> + grlib_apbuart_can_receive,
> + grlib_apbuart_receive,
> + grlib_apbuart_event,
> + uart, NULL, true);
> }
>
> static void grlib_apbuart_reset(DeviceState *d)
> @@ -280,9 +284,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;
> }
> @@ -291,6 +294,7 @@ static const TypeInfo grlib_apbuart_info = {
> .name = TYPE_GRLIB_APB_UART,
> .parent = TYPE_SYS_BUS_DEVICE,
> .instance_size = sizeof(UART),
> + .instance_init = grlib_apbuart_init,
> .class_init = grlib_apbuart_class_init,
> };
Reviewed-by: Peter Maydell <address@hidden>
This is a SPARC board device so it should go via the sparc tree.
thanks
-- PMM
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-arm] [Qemu-devel] [PATCH 2/2] hw/char: QOM'ify grlib_apbuart.c,
Peter Maydell <=