From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQtKe-0003I9-VS for qemu-devel@nongnu.org; Thu, 26 Feb 2015 02:58:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQtKc-0000eE-98 for qemu-devel@nongnu.org; Thu, 26 Feb 2015 02:58:04 -0500 Received: from cantor2.suse.de ([195.135.220.15]:36739 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQtKb-0000e0-VD for qemu-devel@nongnu.org; Thu, 26 Feb 2015 02:58:02 -0500 Message-ID: <54EED207.1070307@suse.de> Date: Thu, 26 Feb 2015 08:57:59 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <889eb6b5efba83c8bb85435fe832eaefc2e70c14.1424926336.git.alistair.francis@xilinx.com> In-Reply-To: <889eb6b5efba83c8bb85435fe832eaefc2e70c14.1424926336.git.alistair.francis@xilinx.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 1/1] char: cadence_uart: Convert to realize() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alistair Francis , qemu-devel@nongnu.org Cc: peter.crosthwaite@xilinx.com Am 26.02.2015 um 06:07 schrieb Alistair Francis: > Use the DeviceClass realize() and init() instead of > the deprecated SysBusDevice init(). >=20 > Signed-off-by: Alistair Francis > --- > V2: > - Simplify commit message > - Fix function typo >=20 > hw/char/cadence_uart.c | 29 ++++++++++++++++------------- > 1 file changed, 16 insertions(+), 13 deletions(-) >=20 > 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); > } > =20 > -static int cadence_uart_init(SysBusDevice *dev) > +static void cadence_uart_realize(DeviceState *dev, Error **errp) > { > UartState *s =3D CADENCE_UART(dev); > =20 > - 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 =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, > - (QEMUTimerCB *)fifo_trigger_update, s); > - > - s->char_tx_time =3D (get_ticks_per_sec() / 9600) * 10; > - > s->chr =3D qemu_char_get_next_serial(); > =20 > if (s->chr) { > qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive, > uart_event, s); > } > +} > =20 > - return 0; > +static void cadence_uart_init(Object *obj) > +{ > + UartState *s =3D 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 =3D 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 =3D (get_ticks_per_sec() / 9600) * 10; > } > =20 > static int cadence_uart_post_load(void *opaque, int version_id) > @@ -528,9 +531,8 @@ static const VMStateDescription vmstate_cadence_uar= t =3D { > static void cadence_uart_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc =3D DEVICE_CLASS(klass); > - SysBusDeviceClass *sdc =3D SYS_BUS_DEVICE_CLASS(klass); > =20 > - sdc->init =3D cadence_uart_init; > + dc->realize =3D cadence_uart_realize; > dc->vmsd =3D &vmstate_cadence_uart; > dc->reset =3D cadence_uart_reset; > } > @@ -539,6 +541,7 @@ static const TypeInfo cadence_uart_info =3D { > .name =3D TYPE_CADENCE_UART, > .parent =3D TYPE_SYS_BUS_DEVICE, > .instance_size =3D sizeof(UartState), > + .instance_init =3D cadence_uart_init, > .class_init =3D cadence_uart_class_init, > }; > =20 >=20 --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Felix Imend=F6rffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG N=FCrnberg)