From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azimp-0006dQ-2i for qemu-devel@nongnu.org; Mon, 09 May 2016 06:51:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azimj-0006V3-22 for qemu-devel@nongnu.org; Mon, 09 May 2016 06:51:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azimi-0006Uz-Sh for qemu-devel@nongnu.org; Mon, 09 May 2016 06:51:32 -0400 References: <1458206430-21917-1-git-send-email-zxq_yx_007@163.com> <1458206430-21917-3-git-send-email-zxq_yx_007@163.com> From: Paolo Bonzini Message-ID: <57306BAE.4060005@redhat.com> Date: Mon, 9 May 2016 12:51:26 +0200 MIME-Version: 1.0 In-Reply-To: <1458206430-21917-3-git-send-email-zxq_yx_007@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/6] hw/char: QOM'ify etraxfs_ser.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xiaoqiang zhao , qemu-devel@nongnu.org Cc: michael@walle.cc, cornelia.huck@de.ibm.com, agraf@suse.de, edgar.iglesias@gmail.com On 17/03/2016 10:20, xiaoqiang zhao wrote: > Drop the old SysBus init function and use instance_init > > Signed-off-by: xiaoqiang zhao > --- > hw/char/etraxfs_ser.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c > index 146b387..ede7024 100644 > --- a/hw/char/etraxfs_ser.c > +++ b/hw/char/etraxfs_ser.c > @@ -209,12 +209,13 @@ static void etraxfs_ser_reset(DeviceState *d) > > } > > -static int etraxfs_ser_init(SysBusDevice *dev) > +static void etraxfs_ser_init(Object *obj) > { > - ETRAXSerial *s = ETRAX_SERIAL(dev); > + ETRAXSerial *s = ETRAX_SERIAL(obj); > + SysBusDevice *dev = SYS_BUS_DEVICE(obj); > > sysbus_init_irq(dev, &s->irq); > - memory_region_init_io(&s->mmio, OBJECT(s), &ser_ops, s, > + memory_region_init_io(&s->mmio, obj, &ser_ops, s, > "etraxfs-serial", R_MAX * 4); > sysbus_init_mmio(dev, &s->mmio); > > @@ -225,15 +226,12 @@ static int etraxfs_ser_init(SysBusDevice *dev) > serial_can_receive, serial_receive, > serial_event, s); The missing context has a qemu_char_get_next_serial() call, so this patch is not good either. Paolo > } > - return 0; > } > > static void etraxfs_ser_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > > - k->init = etraxfs_ser_init; > dc->reset = etraxfs_ser_reset; > /* Reason: init() method uses qemu_char_get_next_serial() */ > dc->cannot_instantiate_with_device_add_yet = true; > @@ -243,6 +241,7 @@ static const TypeInfo etraxfs_ser_info = { > .name = TYPE_ETRAX_FS_SERIAL, > .parent = TYPE_SYS_BUS_DEVICE, > .instance_size = sizeof(ETRAXSerial), > + .instance_init = etraxfs_ser_init, > .class_init = etraxfs_ser_class_init, > }; > >