qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize()
@ 2015-02-27  1:48 Alistair Francis
  2015-02-27 17:59 ` Andreas Färber
  0 siblings, 1 reply; 6+ messages in thread
From: Alistair Francis @ 2015-02-27  1:48 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>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
V3:
 - Move the timer_new_ns() function to realize
 - Remove the QEMUTimerCB cast
V2:
 - Simplfy commit message
 - Fix function typo

 hw/char/cadence_uart.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 7044b35..a713a08 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,17 @@ 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)
+{
+    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->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,
 };
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize()
  2015-02-27  1:48 [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize() Alistair Francis
@ 2015-02-27 17:59 ` Andreas Färber
  2015-02-28  8:52   ` Alistair Francis
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Färber @ 2015-02-27 17:59 UTC (permalink / raw)
  To: Alistair Francis, qemu-devel; +Cc: peter.crosthwaite

Am 27.02.2015 um 02:48 schrieb Alistair Francis:
> Use the DeviceClass realize() and init() instead of
> the deprecated SysBusDevice init().
> 
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Thanks, applied to qom-next with some wording/syntax changes and the
following QOM cast cleanup:

diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index a713a08..36084d5 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -494,10 +494,11 @@ static void cadence_uart_realize(DeviceState *dev,
Error **errp)
 static void cadence_uart_init(Object *obj)
 {
     UartState *s = CADENCE_UART(obj);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(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);
+    sysbus_init_mmio(sbd, &s->iomem);
+    sysbus_init_irq(sbd, &s->irq);

     s->char_tx_time = (get_ticks_per_sec() / 9600) * 10;
 }

fixing myself up with the canonical order:

diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 36084d5..a5dc2a4 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -493,8 +493,8 @@ static void cadence_uart_realize(DeviceState *dev,
Error **errp)

 static void cadence_uart_init(Object *obj)
 {
-    UartState *s = CADENCE_UART(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);

https://github.com/afaerber/qemu-cpu/commits/qom-next

Regards,
Andreas

-- 
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 related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize()
  2015-02-27 17:59 ` Andreas Färber
@ 2015-02-28  8:52   ` Alistair Francis
  2015-03-16 23:19     ` Alistair Francis
  0 siblings, 1 reply; 6+ messages in thread
From: Alistair Francis @ 2015-02-28  8:52 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Peter Crosthwaite, qemu-devel@nongnu.org Developers,
	Alistair Francis

On Sat, Feb 28, 2015 at 3:59 AM, Andreas Färber <afaerber@suse.de> wrote:
> Am 27.02.2015 um 02:48 schrieb Alistair Francis:
>> Use the DeviceClass realize() and init() instead of
>> the deprecated SysBusDevice init().
>>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Thanks, applied to qom-next with some wording/syntax changes and the
> following QOM cast cleanup:
>
> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
> index a713a08..36084d5 100644
> --- a/hw/char/cadence_uart.c
> +++ b/hw/char/cadence_uart.c
> @@ -494,10 +494,11 @@ static void cadence_uart_realize(DeviceState *dev,
> Error **errp)
>  static void cadence_uart_init(Object *obj)
>  {
>      UartState *s = CADENCE_UART(obj);
> +    SysBusDevice *sbd = SYS_BUS_DEVICE(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);
> +    sysbus_init_mmio(sbd, &s->iomem);
> +    sysbus_init_irq(sbd, &s->irq);
>
>      s->char_tx_time = (get_ticks_per_sec() / 9600) * 10;
>  }
>
> fixing myself up with the canonical order:
>
> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
> index 36084d5..a5dc2a4 100644
> --- a/hw/char/cadence_uart.c
> +++ b/hw/char/cadence_uart.c
> @@ -493,8 +493,8 @@ static void cadence_uart_realize(DeviceState *dev,
> Error **errp)
>
>  static void cadence_uart_init(Object *obj)
>  {
> -    UartState *s = CADENCE_UART(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);
>
> https://github.com/afaerber/qemu-cpu/commits/qom-next

Looks good, thanks for taking it via qom-next.

Thanks,

Alistair

>
> Regards,
> Andreas
>
> --
> 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] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize()
  2015-02-28  8:52   ` Alistair Francis
@ 2015-03-16 23:19     ` Alistair Francis
  2015-03-16 23:35       ` Andreas Färber
  0 siblings, 1 reply; 6+ messages in thread
From: Alistair Francis @ 2015-03-16 23:19 UTC (permalink / raw)
  To: Alistair Francis
  Cc: Peter Crosthwaite, Andreas Färber,
	qemu-devel@nongnu.org Developers

On Sat, Feb 28, 2015 at 6:52 PM, Alistair Francis
<alistair.francis@xilinx.com> wrote:
> On Sat, Feb 28, 2015 at 3:59 AM, Andreas Färber <afaerber@suse.de> wrote:
>> Am 27.02.2015 um 02:48 schrieb Alistair Francis:
>>> Use the DeviceClass realize() and init() instead of
>>> the deprecated SysBusDevice init().
>>>
>>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>>> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>
>> Thanks, applied to qom-next with some wording/syntax changes and the
>> following QOM cast cleanup:

I haven't seen the pull request for this one yet. Is it going into 2.3?

Thanks,

Alistair

>>
>> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
>> index a713a08..36084d5 100644
>> --- a/hw/char/cadence_uart.c
>> +++ b/hw/char/cadence_uart.c
>> @@ -494,10 +494,11 @@ static void cadence_uart_realize(DeviceState *dev,
>> Error **errp)
>>  static void cadence_uart_init(Object *obj)
>>  {
>>      UartState *s = CADENCE_UART(obj);
>> +    SysBusDevice *sbd = SYS_BUS_DEVICE(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);
>> +    sysbus_init_mmio(sbd, &s->iomem);
>> +    sysbus_init_irq(sbd, &s->irq);
>>
>>      s->char_tx_time = (get_ticks_per_sec() / 9600) * 10;
>>  }
>>
>> fixing myself up with the canonical order:
>>
>> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
>> index 36084d5..a5dc2a4 100644
>> --- a/hw/char/cadence_uart.c
>> +++ b/hw/char/cadence_uart.c
>> @@ -493,8 +493,8 @@ static void cadence_uart_realize(DeviceState *dev,
>> Error **errp)
>>
>>  static void cadence_uart_init(Object *obj)
>>  {
>> -    UartState *s = CADENCE_UART(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);
>>
>> https://github.com/afaerber/qemu-cpu/commits/qom-next
>
> Looks good, thanks for taking it via qom-next.
>
> Thanks,
>
> Alistair
>
>>
>> Regards,
>> Andreas
>>
>> --
>> 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] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize()
  2015-03-16 23:19     ` Alistair Francis
@ 2015-03-16 23:35       ` Andreas Färber
  2015-03-16 23:45         ` Alistair Francis
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Färber @ 2015-03-16 23:35 UTC (permalink / raw)
  To: Alistair Francis; +Cc: Peter Crosthwaite, qemu-devel@nongnu.org Developers

Am 17.03.2015 um 00:19 schrieb Alistair Francis:
> On Sat, Feb 28, 2015 at 6:52 PM, Alistair Francis
> <alistair.francis@xilinx.com> wrote:
>> On Sat, Feb 28, 2015 at 3:59 AM, Andreas Färber <afaerber@suse.de> wrote:
>>> Am 27.02.2015 um 02:48 schrieb Alistair Francis:
>>>> Use the DeviceClass realize() and init() instead of
>>>> the deprecated SysBusDevice init().
>>>>
>>>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>>>> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>>
>>> Thanks, applied to qom-next with some wording/syntax changes and the
>>> following QOM cast cleanup:
> 
> I haven't seen the pull request for this one yet. Is it going into 2.3?

It is currently the only patch in my queue - was hoping to send a pull
together with some patches from my HMP patchset. Second pair of eyes or
quick testing welcome!

Thanks,
Andreas

-- 
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] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize()
  2015-03-16 23:35       ` Andreas Färber
@ 2015-03-16 23:45         ` Alistair Francis
  0 siblings, 0 replies; 6+ messages in thread
From: Alistair Francis @ 2015-03-16 23:45 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Peter Crosthwaite, qemu-devel@nongnu.org Developers,
	Alistair Francis

On Tue, Mar 17, 2015 at 9:35 AM, Andreas Färber <afaerber@suse.de> wrote:
> Am 17.03.2015 um 00:19 schrieb Alistair Francis:
>> On Sat, Feb 28, 2015 at 6:52 PM, Alistair Francis
>> <alistair.francis@xilinx.com> wrote:
>>> On Sat, Feb 28, 2015 at 3:59 AM, Andreas Färber <afaerber@suse.de> wrote:
>>>> Am 27.02.2015 um 02:48 schrieb Alistair Francis:
>>>>> Use the DeviceClass realize() and init() instead of
>>>>> the deprecated SysBusDevice init().
>>>>>
>>>>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>>>>> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>>>
>>>> Thanks, applied to qom-next with some wording/syntax changes and the
>>>> following QOM cast cleanup:
>>
>> I haven't seen the pull request for this one yet. Is it going into 2.3?
>
> It is currently the only patch in my queue - was hoping to send a pull
> together with some patches from my HMP patchset. Second pair of eyes or
> quick testing welcome!

Great, thanks. I'll try to read over you HMP patchset today.

Thanks,

Alistair

>
> Thanks,
> Andreas
>
> --
> 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] 6+ messages in thread

end of thread, other threads:[~2015-03-16 23:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27  1:48 [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize() Alistair Francis
2015-02-27 17:59 ` Andreas Färber
2015-02-28  8:52   ` Alistair Francis
2015-03-16 23:19     ` Alistair Francis
2015-03-16 23:35       ` Andreas Färber
2015-03-16 23:45         ` Alistair Francis

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).