[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v13 02/19] i.MX: Move serial initialization to init/
From: |
Jean-Christophe Dubois |
Subject: |
[Qemu-devel] [PATCH v13 02/19] i.MX: Move serial initialization to init/realize of DeviceClass. |
Date: |
Thu, 16 Jul 2015 23:21:15 +0200 |
Move constructor to DeviceClass methods
* imx_serial_init
* imx_serial_realize
imx32_serial_properties is renamed to imx_serial_properties.
Signed-off-by: Jean-Christophe Dubois <address@hidden>
Reviewed-by: Peter Crosthwaite <address@hidden>
---
Changes since v1:
* not present on v1
Changes since v2:
* not present on v2
Changes since v3:
* not present on v3
Changes since v4:
* not present on v4
Changes since v5:
* not present on v5
Changes since v6:
* not present on v6
Changes since v7:
* not present on v7
Changes since v8:
* Remove Qdev construction helper
Changes since v9:
* Qdev construction helper is reintegrated and moved to a header file
as an inline function.
Changes since v10:
* Qdev construction helper is put back in the main file.
* Qdev construction helper is reworked
* We don't use qemu_char_get_next_serial() anymore but the chardev
property instead.
* Fix code to work with an unitialized (null) chardev property
Changes since v11:
* remove fix to work with an unitialized (null) chardev property
* restore Qdev construction helper to initial state.
Changes since v12:
* move some coding style fixes to patch 03
hw/char/imx_serial.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
index 1dcb325..f0ed255 100644
--- a/hw/char/imx_serial.c
+++ b/hw/char/imx_serial.c
@@ -306,16 +306,10 @@ static const struct MemoryRegionOps imx_serial_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int imx_serial_init(SysBusDevice *dev)
+static void imx_serial_realize(DeviceState *dev, Error **errp)
{
IMXSerialState *s = IMX_SERIAL(dev);
-
- memory_region_init_io(&s->iomem, OBJECT(s), &imx_serial_ops, s,
- "imx-serial", 0x1000);
- sysbus_init_mmio(dev, &s->iomem);
- sysbus_init_irq(dev, &s->irq);
-
if (s->chr) {
qemu_chr_add_handlers(s->chr, imx_can_receive, imx_receive,
imx_event, s);
@@ -323,8 +317,17 @@ static int imx_serial_init(SysBusDevice *dev)
DPRINTF("No char dev for uart at 0x%lx\n",
(unsigned long)s->iomem.ram_addr);
}
+}
+
+static void imx_serial_init(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ IMXSerialState *s = IMX_SERIAL(obj);
- return 0;
+ memory_region_init_io(&s->iomem, obj, &imx_serial_ops, s,
+ TYPE_IMX_SERIAL, 0x1000);
+ sysbus_init_mmio(sbd, &s->iomem);
+ sysbus_init_irq(sbd, &s->irq);
}
void imx_serial_create(int uart, const hwaddr addr, qemu_irq irq)
@@ -361,7 +364,7 @@ void imx_serial_create(int uart, const hwaddr addr,
qemu_irq irq)
}
-static Property imx32_serial_properties[] = {
+static Property imx_serial_properties[] = {
DEFINE_PROP_CHR("chardev", IMXSerialState, chr),
DEFINE_PROP_END_OF_LIST(),
};
@@ -369,21 +372,21 @@ static Property imx32_serial_properties[] = {
static void imx_serial_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = imx_serial_init;
+ dc->realize = imx_serial_realize;
dc->vmsd = &vmstate_imx_serial;
dc->reset = imx_serial_reset_at_boot;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
dc->desc = "i.MX series UART";
- dc->props = imx32_serial_properties;
+ dc->props = imx_serial_properties;
}
static const TypeInfo imx_serial_info = {
- .name = TYPE_IMX_SERIAL,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(IMXSerialState),
- .class_init = imx_serial_class_init,
+ .name = TYPE_IMX_SERIAL,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(IMXSerialState),
+ .instance_init = imx_serial_init,
+ .class_init = imx_serial_class_init,
};
static void imx_serial_register_types(void)
--
2.1.4
- [Qemu-devel] [PATCH v13 00/19] i.MX: Add i.MX25 support through the PDK evaluation board, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 02/19] i.MX: Move serial initialization to init/realize of DeviceClass.,
Jean-Christophe Dubois <=
- [Qemu-devel] [PATCH v13 01/19] i.MX: Split UART emulator in a header file and a source file, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 03/19] i.MX:Fix Coding style for UART emulator., Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 04/19] i.MX: Split AVIC emulator in a header file and a source file, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 06/19] i.MX: Split CCM emulator in a header file and a source file, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 05/19] i.MX: Fix Coding style for AVIC emulator., Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 07/19] i.MX: Fix Coding style for CCM emulator, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 08/19] i.MX: Split EPIT emulator in a header file and a source file, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 09/19] i.MX: Fix Coding style for EPIT emulator, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 10/19] i.MX: Split GPT emulator in a header file and a source file, Jean-Christophe Dubois, 2015/07/16
- [Qemu-devel] [PATCH v13 11/19] i.MX: Fix Coding style for GPT emulator, Jean-Christophe Dubois, 2015/07/16