qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] floppy: add drive properties.
Date: Fri, 18 Sep 2009 16:34:10 +0200	[thread overview]
Message-ID: <87k4zw490d.fsf@pike.pond.sub.org> (raw)
In-Reply-To: <1253132744-10492-2-git-send-email-kraxel@redhat.com> (Gerd Hoffmann's message of "Wed\, 16 Sep 2009 22\:25\:40 +0200")

Gerd Hoffmann <kraxel@redhat.com> writes:

> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/fdc.c        |   50 +++++++++++++++++++++++++++++++++++++-------------
>  hw/fdc.h        |    7 ++++---
>  hw/mips_jazz.c  |    5 ++---
>  hw/mips_malta.c |    5 ++---
>  hw/pc.c         |    6 ++----
>  hw/ppc_prep.c   |    6 ++----
>  hw/sun4m.c      |   16 ++++------------
>  hw/sun4u.c      |    6 ++----
>  8 files changed, 55 insertions(+), 46 deletions(-)
>
> diff --git a/hw/fdc.c b/hw/fdc.c
> index 389d9e6..ea3b8ac 100644
> --- a/hw/fdc.c
> +++ b/hw/fdc.c
[...]
> @@ -1829,43 +1830,50 @@ static void fdctrl_result_timer(void *opaque)
>  }
>  
>  /* Init functions */
> -static void fdctrl_connect_drives(fdctrl_t *fdctrl, BlockDriverState **fds)
> +static void fdctrl_connect_drives(fdctrl_t *fdctrl)
>  {
>      unsigned int i;
>  
>      for (i = 0; i < MAX_FD; i++) {
> -        fd_init(&fdctrl->drives[i], fds[i]);
> +        fd_init(&fdctrl->drives[i]);
>          fd_revalidate(&fdctrl->drives[i]);
>      }
>  }
>  
> -fdctrl_t *fdctrl_init_isa(BlockDriverState **fds)
> +fdctrl_t *fdctrl_init_isa(DriveInfo **fds)
>  {
>      fdctrl_t *fdctrl;
>      ISADevice *dev;
>      int dma_chann = 2;
>  
> -    dev = isa_create_simple("isa-fdc");
> +    dev = isa_create("isa-fdc");
> +    qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]);
> +    qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]);
> +    if (qdev_init(&dev->qdev) != 0)
> +        return NULL;

Callers never check for failure.  Recommend qdev_init_nofail(), except
that's not merged, yet.

>      fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
>  
>      fdctrl->dma_chann = dma_chann;
>      DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl);
>  
> -    fdctrl_connect_drives(fdctrl, fds);
> +    fdctrl_connect_drives(fdctrl);
>  
>      return fdctrl;
>  }
>  
>  fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
>                               target_phys_addr_t mmio_base,
> -                             BlockDriverState **fds)
> +                             DriveInfo **fds)
>  {
>      fdctrl_t *fdctrl;
>      DeviceState *dev;
>      fdctrl_sysbus_t *sys;
>  
>      dev = qdev_create(NULL, "sysbus-fdc");
> -    qdev_init(dev);
> +    qdev_prop_set_drive(dev, "driveA", fds[0]);
> +    qdev_prop_set_drive(dev, "driveB", fds[1]);
> +    if (qdev_init(dev) != 0)
> +        return NULL;

Ditto.

>      sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
>      fdctrl = &sys->state;
>      sysbus_connect_irq(&sys->busdev, 0, irq);
> @@ -1873,20 +1881,22 @@ fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
>  
>      fdctrl->dma_chann = dma_chann;
>      DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl);
> -    fdctrl_connect_drives(fdctrl, fds);
> +    fdctrl_connect_drives(fdctrl);
>  
>      return fdctrl;
>  }
>  
>  fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,
> -                             BlockDriverState **fds, qemu_irq *fdc_tc)
> +                             DriveInfo **fds, qemu_irq *fdc_tc)
>  {
>      DeviceState *dev;
>      fdctrl_sysbus_t *sys;
>      fdctrl_t *fdctrl;
>  
>      dev = qdev_create(NULL, "SUNW,fdtwo");
> -    qdev_init(dev);
> +    qdev_prop_set_drive(dev, "drive", fds[0]);
> +    if (qdev_init(dev) != 0)
> +        return NULL;

Ditto.

>      sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
>      fdctrl = &sys->state;
>      sysbus_connect_irq(&sys->busdev, 0, irq);
[...]

  reply	other threads:[~2009-09-18 14:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-16 20:25 [Qemu-devel] [PATCH 0/5] isa: more qdev conversions Gerd Hoffmann
2009-09-16 20:25 ` [Qemu-devel] [PATCH 1/5] floppy: add drive properties Gerd Hoffmann
2009-09-18 14:34   ` Markus Armbruster [this message]
2009-09-16 20:25 ` [Qemu-devel] [PATCH 2/5] floppy: move dma setup + drive connect to fdctrl_init_common() Gerd Hoffmann
2009-09-18 14:48   ` Markus Armbruster
2009-09-18 14:58     ` Gerd Hoffmann
2009-09-16 20:25 ` [Qemu-devel] [PATCH 3/5] qdev: don't crash on unset drive properties Gerd Hoffmann
2009-09-16 20:25 ` [Qemu-devel] [PATCH 4/5] serial: convert isa to qdev Gerd Hoffmann
2009-09-18 15:04   ` Markus Armbruster
2009-09-18 15:18     ` Gerd Hoffmann
2009-09-16 20:25 ` [Qemu-devel] [PATCH 5/5] parallel: " Gerd Hoffmann
2009-09-18 15:10   ` Markus Armbruster
2009-09-18 15:11 ` [Qemu-devel] [PATCH 0/5] isa: more qdev conversions Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2009-09-22 11:53 Gerd Hoffmann
2009-09-22 11:53 ` [Qemu-devel] [PATCH 1/5] floppy: add drive properties Gerd Hoffmann

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=87k4zw490d.fsf@pike.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).