aboutsummaryrefslogtreecommitdiff
path: root/hw/char
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@xilinx.com>2015-02-27 11:48:58 +1000
committerAndreas Färber <afaerber@suse.de>2015-03-17 14:06:36 +0100
commit96f209264f642365052983dcb50a0f3d7b688f6b (patch)
tree7c4ee2ccbca6464194a3cf77a6cf1cd49888909c /hw/char
parent5a4992834daec85c3913654903fb9f4f954e585a (diff)
downloadqemu-96f209264f642365052983dcb50a0f3d7b688f6b.zip
qemu-96f209264f642365052983dcb50a0f3d7b688f6b.tar.gz
qemu-96f209264f642365052983dcb50a0f3d7b688f6b.tar.bz2
cadence_uart: Convert to QOM realize()
Use DeviceClass::realize() and TypeInfo::instance_init() instead of the deprecated SysBusDevice::init(). Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/char')
-rw-r--r--hw/char/cadence_uart.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 7044b35..a5dc2a4 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -476,18 +476,12 @@ static void cadence_uart_reset(DeviceState *dev)
uart_update_status(s);
}
-static int cadence_uart_init(SysBusDevice *dev)
+static void cadence_uart_realize(DeviceState *dev, Error **errp)
{
UartState *s = CADENCE_UART(dev);
- memory_region_init_io(&s->iomem, OBJECT(s), &uart_ops, s, "uart", 0x1000);
- sysbus_init_mmio(dev, &s->iomem);
- sysbus_init_irq(dev, &s->irq);
-
s->fifo_trigger_handle = timer_new_ns(QEMU_CLOCK_VIRTUAL,
- (QEMUTimerCB *)fifo_trigger_update, s);
-
- s->char_tx_time = (get_ticks_per_sec() / 9600) * 10;
+ fifo_trigger_update, s);
s->chr = qemu_char_get_next_serial();
@@ -495,8 +489,18 @@ static int cadence_uart_init(SysBusDevice *dev)
qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive,
uart_event, s);
}
+}
- return 0;
+static void cadence_uart_init(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ UartState *s = CADENCE_UART(obj);
+
+ memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000);
+ sysbus_init_mmio(sbd, &s->iomem);
+ sysbus_init_irq(sbd, &s->irq);
+
+ s->char_tx_time = (get_ticks_per_sec() / 9600) * 10;
}
static int cadence_uart_post_load(void *opaque, int version_id)
@@ -528,9 +532,8 @@ static const VMStateDescription vmstate_cadence_uart = {
static void cadence_uart_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
- sdc->init = cadence_uart_init;
+ dc->realize = cadence_uart_realize;
dc->vmsd = &vmstate_cadence_uart;
dc->reset = cadence_uart_reset;
}
@@ -539,6 +542,7 @@ static const TypeInfo cadence_uart_info = {
.name = TYPE_CADENCE_UART,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(UartState),
+ .instance_init = cadence_uart_init,
.class_init = cadence_uart_class_init,
};