All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org, John Snow <jsnow@redhat.com>
Cc: "Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH v5 6/6] hw/block/fdc: Add sysbus_fdc_init_drives() method
Date: Tue, 18 May 2021 21:32:39 +0200	[thread overview]
Message-ID: <20210518193239.1725624-7-philmd@redhat.com> (raw)
In-Reply-To: <20210518193239.1725624-1-philmd@redhat.com>

FDCtrlSysBus's FDCtrl state is a private field. However it is
accessed by the public fdctrl_init_sysbus() and sun4m_fdctrl_init()
methods. To be able to move them out of fdc-sysbus.c, first add
the sysbus_fdc_init_drives() method and use it in these 2 functions.

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/hw/block/fdc.h |  2 ++
 hw/block/fdc-sysbus.c  | 23 ++++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h
index 1ecca7cac7f..52e45c53078 100644
--- a/include/hw/block/fdc.h
+++ b/include/hw/block/fdc.h
@@ -3,6 +3,7 @@
 
 #include "exec/hwaddr.h"
 #include "qapi/qapi-types-block.h"
+#include "hw/sysbus.h"
 
 /* fdc.c */
 #define MAX_FD 2
@@ -10,6 +11,7 @@
 #define TYPE_ISA_FDC "isa-fdc"
 
 void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds);
+void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds);
 void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
                         hwaddr mmio_base, DriveInfo **fds);
 void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c
index c6308f53004..e4105407280 100644
--- a/hw/block/fdc-sysbus.c
+++ b/hw/block/fdc-sysbus.c
@@ -94,6 +94,15 @@ static void fdctrl_handle_tc(void *opaque, int irq, int level)
     trace_fdctrl_tc_pulse(level);
 }
 
+void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds)
+{
+    FDCtrlSysBus *fdc;
+
+    fdc = SYSBUS_FDC(dev);
+
+    fdctrl_init_drives(&fdc->state.bus, fds);
+}
+
 void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
                         hwaddr mmio_base, DriveInfo **fds)
 {
@@ -111,23 +120,23 @@ void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
     sysbus_connect_irq(sbd, 0, irq);
     sysbus_mmio_map(sbd, 0, mmio_base);
 
-    fdctrl_init_drives(&sys->state.bus, fds);
+    sysbus_fdc_init_drives(sbd, fds);
 }
 
 void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
                        DriveInfo **fds, qemu_irq *fdc_tc)
 {
     DeviceState *dev;
-    FDCtrlSysBus *sys;
+    SysBusDevice *sbd;
 
     dev = qdev_new("sun-fdtwo");
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
-    sys = SYSBUS_FDC(dev);
-    sysbus_connect_irq(SYS_BUS_DEVICE(sys), 0, irq);
-    sysbus_mmio_map(SYS_BUS_DEVICE(sys), 0, io_base);
+    sbd = SYS_BUS_DEVICE(dev);
+    sysbus_realize_and_unref(sbd, &error_fatal);
+    sysbus_connect_irq(sbd, 0, irq);
+    sysbus_mmio_map(sbd, 0, io_base);
     *fdc_tc = qdev_get_gpio_in(dev, 0);
 
-    fdctrl_init_drives(&sys->state.bus, fds);
+    sysbus_fdc_init_drives(sbd, fds);
 }
 
 static void sysbus_fdc_common_instance_init(Object *obj)
-- 
2.26.3



      parent reply	other threads:[~2021-05-18 19:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 19:32 [PATCH v5 0/6] hw/block/fdc: Allow Kconfig-selecting ISA bus/SysBus floppy controllers Philippe Mathieu-Daudé
2021-05-18 19:32 ` [PATCH v5 1/6] hw/isa/Kconfig: Fix missing dependency ISA_SUPERIO -> FDC Philippe Mathieu-Daudé
2021-05-19  8:23   ` Thomas Huth
2021-05-19 11:05     ` Philippe Mathieu-Daudé
2021-05-20  7:16       ` Thomas Huth
2021-05-18 19:32 ` [PATCH v5 2/6] hw/block/fdc: Replace disabled fprintf() by trace event Philippe Mathieu-Daudé
2021-05-18 19:32 ` [PATCH v5 3/6] hw/block/fdc: Declare shared prototypes in fdc-internal.h Philippe Mathieu-Daudé
2021-05-18 19:32 ` [PATCH v5 4/6] hw/block/fdc: Extract ISA floppy controllers to fdc-isa.c Philippe Mathieu-Daudé
2021-05-18 19:32 ` [PATCH v5 5/6] hw/block/fdc: Extract SysBus floppy controllers to fdc-sysbus.c Philippe Mathieu-Daudé
2021-05-18 19:32 ` Philippe Mathieu-Daudé [this message]

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=20210518193239.1725624-7-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.