* [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize()
@ 2015-02-26 5:07 Alistair Francis
2015-02-26 7:57 ` Andreas Färber
2015-02-26 8:24 ` Peter Crosthwaite
0 siblings, 2 replies; 4+ messages in thread
From: Alistair Francis @ 2015-02-26 5:07 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.crosthwaite, afaerber, alistair.francis
Use the DeviceClass realize() and init() instead of
the deprecated SysBusDevice init().
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
V2:
- Simplify commit message
- Fix function typo
hw/char/cadence_uart.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 7044b35..b6ccd72 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -476,27 +476,30 @@ 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;
-
s->chr = qemu_char_get_next_serial();
if (s->chr) {
qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive,
uart_event, s);
}
+}
- return 0;
+static void cadence_uart_init(Object *obj)
+{
+ UartState *s = CADENCE_UART(obj);
+
+ memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000);
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
+ sysbus_init_irq(SYS_BUS_DEVICE(obj), &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;
}
static int cadence_uart_post_load(void *opaque, int version_id)
@@ -528,9 +531,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 +541,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,
};
--
2.1.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize()
2015-02-26 5:07 [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize() Alistair Francis
@ 2015-02-26 7:57 ` Andreas Färber
2015-02-26 23:49 ` Alistair Francis
2015-02-26 8:24 ` Peter Crosthwaite
1 sibling, 1 reply; 4+ messages in thread
From: Andreas Färber @ 2015-02-26 7:57 UTC (permalink / raw)
To: Alistair Francis, qemu-devel; +Cc: peter.crosthwaite
Am 26.02.2015 um 06:07 schrieb Alistair Francis:
> Use the DeviceClass realize() and init() instead of
> the deprecated SysBusDevice init().
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
> V2:
> - Simplify commit message
> - Fix function typo
>
> hw/char/cadence_uart.c | 29 ++++++++++++++++-------------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
> index 7044b35..b6ccd72 100644
> --- a/hw/char/cadence_uart.c
> +++ b/hw/char/cadence_uart.c
> @@ -476,27 +476,30 @@ 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;
> -
> s->chr = qemu_char_get_next_serial();
>
> if (s->chr) {
> qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive,
> uart_event, s);
> }
> +}
>
> - return 0;
> +static void cadence_uart_init(Object *obj)
> +{
> + UartState *s = CADENCE_UART(obj);
> +
> + memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000);
> + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
> + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq);
> +
> + s->fifo_trigger_handle = timer_new_ns(QEMU_CLOCK_VIRTUAL,
> + (QEMUTimerCB *)fifo_trigger_update, s);
Is the timer created in a non-running state? Otherwise it should
probably remain in realize.
Also, why is the cast necessary?
Otherwise looks good. Via qom-next tree or ARM tree?
Regards,
Andreas
> +
> + s->char_tx_time = (get_ticks_per_sec() / 9600) * 10;
> }
>
> static int cadence_uart_post_load(void *opaque, int version_id)
> @@ -528,9 +531,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 +541,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,
> };
>
>
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize()
2015-02-26 5:07 [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize() Alistair Francis
2015-02-26 7:57 ` Andreas Färber
@ 2015-02-26 8:24 ` Peter Crosthwaite
1 sibling, 0 replies; 4+ messages in thread
From: Peter Crosthwaite @ 2015-02-26 8:24 UTC (permalink / raw)
To: Alistair Francis; +Cc: qemu-devel@nongnu.org Developers, Andreas Färber
On Wed, Feb 25, 2015 at 9:07 PM, Alistair Francis
<alistair.francis@xilinx.com> wrote:
> Use the DeviceClass realize() and init() instead of
> the deprecated SysBusDevice init().
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
With Andreas' comments addressed:
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Regards,
Peter
> ---
> V2:
> - Simplify commit message
> - Fix function typo
>
> hw/char/cadence_uart.c | 29 ++++++++++++++++-------------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
> index 7044b35..b6ccd72 100644
> --- a/hw/char/cadence_uart.c
> +++ b/hw/char/cadence_uart.c
> @@ -476,27 +476,30 @@ 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;
> -
> s->chr = qemu_char_get_next_serial();
>
> if (s->chr) {
> qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive,
> uart_event, s);
> }
> +}
>
> - return 0;
> +static void cadence_uart_init(Object *obj)
> +{
> + UartState *s = CADENCE_UART(obj);
> +
> + memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000);
> + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
> + sysbus_init_irq(SYS_BUS_DEVICE(obj), &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;
> }
>
> static int cadence_uart_post_load(void *opaque, int version_id)
> @@ -528,9 +531,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 +541,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,
> };
>
> --
> 2.1.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize()
2015-02-26 7:57 ` Andreas Färber
@ 2015-02-26 23:49 ` Alistair Francis
0 siblings, 0 replies; 4+ messages in thread
From: Alistair Francis @ 2015-02-26 23:49 UTC (permalink / raw)
To: Andreas Färber
Cc: Peter Crosthwaite, qemu-devel@nongnu.org Developers,
Alistair Francis
On Thu, Feb 26, 2015 at 5:57 PM, Andreas Färber <afaerber@suse.de> wrote:
> Am 26.02.2015 um 06:07 schrieb Alistair Francis:
>> Use the DeviceClass realize() and init() instead of
>> the deprecated SysBusDevice init().
>>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>> ---
>> V2:
>> - Simplify commit message
>> - Fix function typo
>>
>> hw/char/cadence_uart.c | 29 ++++++++++++++++-------------
>> 1 file changed, 16 insertions(+), 13 deletions(-)
>>
>> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
>> index 7044b35..b6ccd72 100644
>> --- a/hw/char/cadence_uart.c
>> +++ b/hw/char/cadence_uart.c
>> @@ -476,27 +476,30 @@ 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;
>> -
>> s->chr = qemu_char_get_next_serial();
>>
>> if (s->chr) {
>> qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive,
>> uart_event, s);
>> }
>> +}
>>
>> - return 0;
>> +static void cadence_uart_init(Object *obj)
>> +{
>> + UartState *s = CADENCE_UART(obj);
>> +
>> + memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000);
>> + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
>> + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq);
>> +
>> + s->fifo_trigger_handle = timer_new_ns(QEMU_CLOCK_VIRTUAL,
>> + (QEMUTimerCB *)fifo_trigger_update, s);
>
> Is the timer created in a non-running state? Otherwise it should
> probably remain in realize.
Not that I'm aware of, I will move it to realize.
>
> Also, why is the cast necessary?
It's not really, it was just already in the code, I will remove it.
>
> Otherwise looks good. Via qom-next tree or ARM tree?
qom-next would be best as Peter is away for the next week.
Thanks,
Alistair
>
> Regards,
> Andreas
>
>> +
>> + s->char_tx_time = (get_ticks_per_sec() / 9600) * 10;
>> }
>>
>> static int cadence_uart_post_load(void *opaque, int version_id)
>> @@ -528,9 +531,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 +541,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,
>> };
>>
>>
>
>
> --
> SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
> Graham Norton; HRB 21284 (AG Nürnberg)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-26 23:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-26 5:07 [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize() Alistair Francis
2015-02-26 7:57 ` Andreas Färber
2015-02-26 23:49 ` Alistair Francis
2015-02-26 8:24 ` Peter Crosthwaite
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).