qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 09/26] fdc: use realize for fdc.
Date: Sun, 21 Jul 2013 11:27:46 +0200	[thread overview]
Message-ID: <51EBA992.6070106@suse.de> (raw)
In-Reply-To: <555ec78d1db05435707ae68d4af4557aea0c3beb.1372673778.git.hutao@cn.fujitsu.com>

Am 01.07.2013 12:18, schrieb Hu Tao:
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/block/fdc.c | 62 ++++++++++++++++++++++++++++++++++++++--------------------
>  1 file changed, 41 insertions(+), 21 deletions(-)
> 
> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
> index f8270cb..0fe0cf9 100644
> --- a/hw/block/fdc.c
> +++ b/hw/block/fdc.c
> @@ -2145,38 +2145,58 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp)
>      add_boot_device_path(isa->bootindexB, dev, "/floppy@1");
>  }
>  
> -static int sysbus_fdc_init1(SysBusDevice *dev)
> +static void sysbus_fdc_initfn(Object *obj)
>  {
> -    FDCtrlSysBus *sys = SYSBUS_FDC(dev);
> +    FDCtrlSysBus *sys = SYSBUS_FDC(obj);
>      FDCtrl *fdctrl = &sys->state;
> -    int ret;
>  
>      memory_region_init_io(&fdctrl->iomem, &fdctrl_mem_ops, fdctrl, "fdc", 0x08);
> -    sysbus_init_mmio(dev, &fdctrl->iomem);
> -    sysbus_init_irq(dev, &fdctrl->irq);
> -    qdev_init_gpio_in(DEVICE(dev), fdctrl_handle_tc, 1);
> -    fdctrl->dma_chann = -1;
> +}
>  
> -    qdev_set_legacy_instance_id(DEVICE(dev), 0 /* io */, 2); /* FIXME */
> -    ret = fdctrl_init_common(fdctrl);
> +static void sysbus_fdc_realize(DeviceState *dev, Error **errp)
> +{
> +    FDCtrlSysBus *sys = SYSBUS_FDC(dev);
> +    FDCtrl *fdctrl = &sys->state;
> +    SysBusDevice *b = SYS_BUS_DEVICE(dev);
>  
> -    return ret;
> +
> +    sysbus_init_mmio(b, &fdctrl->iomem);
> +    sysbus_init_irq(b, &fdctrl->irq);
> +    qdev_init_gpio_in(dev, fdctrl_handle_tc, 1);
> +    fdctrl->dma_chann = -1;
> +
> +    qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */
> +    if (fdctrl_init_common(fdctrl) < 0) {
> +        error_setg(errp, "Floppy init failed.");
> +        return;
> +    }
>  }
>  
> -static int sun4m_fdc_init1(SysBusDevice *dev)
> +static void sun4m_fdc_initfn(Object *obj)
>  {
> -    FDCtrlSysBus *sys = SYSBUS_FDC(dev);
> +    FDCtrlSysBus *sys = SYSBUS_FDC(obj);
>      FDCtrl *fdctrl = &sys->state;
>  
>      memory_region_init_io(&fdctrl->iomem, &fdctrl_mem_strict_ops, fdctrl,
>                            "fdctrl", 0x08);
> -    sysbus_init_mmio(dev, &fdctrl->iomem);
> -    sysbus_init_irq(dev, &fdctrl->irq);
> -    qdev_init_gpio_in(DEVICE(dev), fdctrl_handle_tc, 1);
> +}
> +
> +static void sun4m_fdc_realize(DeviceState *dev, Error **errp)
> +{
> +    FDCtrlSysBus *sys = SYSBUS_FDC(dev);
> +    FDCtrl *fdctrl = &sys->state;
> +    SysBusDevice *b = SYS_BUS_DEVICE(dev);

I've renamed this variable to Peter's suggested sbd and posted a
follow-up to rename fdctrl_init_common() to fdctrl_realize_common() and
to propagate Error** from fdctrl_connect_drives() directly into the
realizefn.

Andreas

> +
> +    sysbus_init_mmio(b, &fdctrl->iomem);
> +    sysbus_init_irq(b, &fdctrl->irq);
> +    qdev_init_gpio_in(dev, fdctrl_handle_tc, 1);
>  
>      fdctrl->sun4m = 1;
> -    qdev_set_legacy_instance_id(DEVICE(dev), 0 /* io */, 2); /* FIXME */
> -    return fdctrl_init_common(fdctrl);
> +    qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */
> +    if (fdctrl_init_common(fdctrl) < 0) {
> +        error_setg(errp, "Floppy init failed.");
> +        return;
> +    }
>  }
>  
>  FDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
> @@ -2247,9 +2267,8 @@ static Property sysbus_fdc_properties[] = {
>  static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> -    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>  
> -    k->init = sysbus_fdc_init1;
> +    dc->realize = sysbus_fdc_realize;
>      dc->reset = fdctrl_external_reset_sysbus;
>      dc->vmsd = &vmstate_sysbus_fdc;
>      dc->props = sysbus_fdc_properties;
> @@ -2259,6 +2278,7 @@ static const TypeInfo sysbus_fdc_info = {
>      .name          = TYPE_SYSBUS_FDC,
>      .parent        = TYPE_SYS_BUS_DEVICE,
>      .instance_size = sizeof(FDCtrlSysBus),
> +    .instance_init = sysbus_fdc_initfn,
>      .class_init    = sysbus_fdc_class_init,
>  };
>  
> @@ -2270,9 +2290,8 @@ static Property sun4m_fdc_properties[] = {
>  static void sun4m_fdc_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> -    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>  
> -    k->init = sun4m_fdc_init1;
> +    dc->realize = sun4m_fdc_realize;
>      dc->reset = fdctrl_external_reset_sysbus;
>      dc->vmsd = &vmstate_sysbus_fdc;
>      dc->props = sun4m_fdc_properties;
> @@ -2282,6 +2301,7 @@ static const TypeInfo sun4m_fdc_info = {
>      .name          = "SUNW,fdtwo",
>      .parent        = TYPE_SYS_BUS_DEVICE,
>      .instance_size = sizeof(FDCtrlSysBus),
> +    .instance_init = sun4m_fdc_initfn,
>      .class_init    = sun4m_fdc_class_init,
>  };
>  
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-07-21  9:27 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01 10:18 [Qemu-devel] [PATCH v2 00/26] use realizefn for SysBusDevice, part 1 Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 01/26] sysbus: document SysBusDeviceClass about @init Hu Tao
2013-07-03  1:19   ` Andreas Färber
2013-07-03  1:24     ` Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 02/26] ohci: QOM'ify some more Hu Tao
2013-07-03  1:52   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 03/26] ohci: use realize for ohci Hu Tao
2013-07-07 15:22   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 04/26] i440fx-pcihost: use realize for i440fx-pcihost Hu Tao
2013-07-07 21:24   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 05/26] i440fx: use type-safe cast instead of directly access of parent dev Hu Tao
2013-07-07 17:03   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 06/26] q35: " Hu Tao
2013-07-07 23:05   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 07/26] q35: use realize for q35 host Hu Tao
2013-07-08  1:20   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 08/26] fdc: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 09/26] fdc: use realize for fdc Hu Tao
2013-07-21  9:27   ` Andreas Färber [this message]
2013-07-21  9:31   ` [Qemu-devel] [PATCH qom-next] fdc: Improve error propagation for QOM realize Andreas Färber
2013-07-22  7:38     ` Hu Tao
2013-07-22  8:26     ` Stefan Hajnoczi
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 10/26] pflash-cfi01: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 11/26] pflash_cfi01: use realize for pflash_cfi01 Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 12/26] pflash-cfi02: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 13/26] pflash_cfi02: use realize for pflash_cfi02 Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 14/26] ahci: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 15/26] ahci: use realize for ahci Hu Tao
2013-07-21  9:13   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 16/26] fwcfg: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 17/26] fwcfg: use realize for fwcfg Hu Tao
2013-07-21  9:35   ` Andreas Färber
2013-07-22  8:37     ` Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 18/26] scsi esp: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 19/26] scsi esp: use realize for scsi esp Hu Tao
2013-07-21  9:47   ` Andreas Färber
2013-07-21 10:30   ` [Qemu-devel] [PATCH qom-next] scsi: Improve error propagation for scsi_bus_legacy_handle_cmdline() Andreas Färber
2013-07-22  9:16     ` Hu Tao
2013-07-22 10:24       ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 20/26] hpet: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 21/26] hpet: use realize for hpet Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 22/26] kvmclock: QOM'ify some more Hu Tao
2013-07-16 14:00   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 23/26] kvmclock: use realize for kvmclock Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 24/26] kvmvapic realize Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 25/26] ioapic: use realize for ioapic Hu Tao
2013-07-21 10:35   ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 26/26] isa bus: remove isabus_bridge_init since it does nothing Hu Tao
2013-07-21 10:58 ` [Qemu-devel] [PATCH v2 00/26] use realizefn for SysBusDevice, part 1 Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51EBA992.6070106@suse.de \
    --to=afaerber@suse.de \
    --cc=hutao@cn.fujitsu.com \
    --cc=kwolf@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).