qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 08/14] ide: Split non-qdev code off ide_init2()
Date: Tue,  1 Jun 2010 20:32:29 +0200	[thread overview]
Message-ID: <1275417155-28244-9-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1275417155-28244-1-git-send-email-armbru@redhat.com>


Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ide/cmd646.c     |    4 ++--
 hw/ide/core.c       |   30 ++++++++++++++++++++++--------
 hw/ide/internal.h   |    5 +++--
 hw/ide/isa.c        |    2 +-
 hw/ide/macio.c      |    2 +-
 hw/ide/microdrive.c |    3 ++-
 hw/ide/mmio.c       |    2 +-
 hw/ide/piix.c       |    4 ++--
 8 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index cdcc9bf..559147f 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -260,8 +260,8 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
     irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
     ide_bus_new(&d->bus[0], &d->dev.qdev);
     ide_bus_new(&d->bus[1], &d->dev.qdev);
-    ide_init2(&d->bus[0], NULL, NULL, irq[0]);
-    ide_init2(&d->bus[1], NULL, NULL, irq[1]);
+    ide_init2(&d->bus[0], irq[0]);
+    ide_init2(&d->bus[1], irq[1]);
 
     vmstate_register(0, &vmstate_ide_pci, d);
     qemu_register_reset(cmd646_reset, d);
diff --git a/hw/ide/core.c b/hw/ide/core.c
index cb7af38..d3328cd 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2632,7 +2632,7 @@ void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version)
     ide_reset(s);
 }
 
-static void ide_init1(IDEBus *bus, int unit, DriveInfo *dinfo)
+static void ide_init1(IDEBus *bus, int unit)
 {
     static int drive_serial = 1;
     IDEState *s = &bus->ifs[unit];
@@ -2645,20 +2645,34 @@ static void ide_init1(IDEBus *bus, int unit, DriveInfo *dinfo)
     s->smart_selftest_data = qemu_blockalign(s->bs, 512);
     s->sector_write_timer = qemu_new_timer(vm_clock,
                                            ide_sector_write_timer_cb, s);
-    if (dinfo) {
-        ide_init_drive(s, dinfo, NULL);
-    } else {
-        ide_reset(s);
+}
+
+void ide_init2(IDEBus *bus, qemu_irq irq)
+{
+    int i;
+
+    for(i = 0; i < 2; i++) {
+        ide_init1(bus, i);
+        ide_reset(&bus->ifs[i]);
     }
+    bus->irq = irq;
 }
 
-void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
-               qemu_irq irq)
+/* TODO convert users to qdev and remove */
+void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
+                                    DriveInfo *hd1, qemu_irq irq)
 {
     int i;
+    DriveInfo *dinfo;
 
     for(i = 0; i < 2; i++) {
-        ide_init1(bus, i, i == 0 ? hd0 : hd1);
+        dinfo = i == 0 ? hd0 : hd1;
+        ide_init1(bus, i);
+        if (dinfo) {
+            ide_init_drive(&bus->ifs[i], dinfo, NULL);
+        } else {
+            ide_reset(&bus->ifs[i]);
+        }
     }
     bus->irq = irq;
 }
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index cf71019..6b0024d 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -555,8 +555,9 @@ void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
 uint32_t ide_data_readl(void *opaque, uint32_t addr);
 
 void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version);
-void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
-               qemu_irq irq);
+void ide_init2(IDEBus *bus, qemu_irq irq);
+void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
+                                    DriveInfo *hd1, qemu_irq irq);
 void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
 
 /* hw/ide/qdev.c */
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index dff7c79..b6c6347 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -70,7 +70,7 @@ static int isa_ide_initfn(ISADevice *dev)
     ide_bus_new(&s->bus, &s->dev.qdev);
     ide_init_ioport(&s->bus, s->iobase, s->iobase2);
     isa_init_irq(dev, &s->irq, s->isairq);
-    ide_init2(&s->bus, NULL, NULL, s->irq);
+    ide_init2(&s->bus, s->irq);
     vmstate_register(0, &vmstate_ide_isa, s);
     return 0;
 };
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 639f3f6..f76c0fa 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -314,7 +314,7 @@ int pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,
     int pmac_ide_memory;
 
     d = qemu_mallocz(sizeof(MACIOIDEState));
-    ide_init2(&d->bus, hd_table[0], hd_table[1], irq);
+    ide_init2_with_non_qdev_drives(&d->bus, hd_table[0], hd_table[1], irq);
 
     if (dbdma)
         DBDMA_register_channel(dbdma, channel, dma_irq, pmac_ide_transfer, pmac_ide_flush, d);
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index bfdb8c8..a7beac5 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -539,7 +539,8 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
     md->card.cis = dscm1xxxx_cis;
     md->card.cis_len = sizeof(dscm1xxxx_cis);
 
-    ide_init2(&md->bus, bdrv, NULL, qemu_allocate_irqs(md_set_irq, md, 1)[0]);
+    ide_init2_with_non_qdev_drives(&md->bus, bdrv, NULL,
+                                   qemu_allocate_irqs(md_set_irq, md, 1)[0]);
     md->bus.ifs[0].is_cf = 1;
     md->bus.ifs[0].mdata_size = METADATA_SIZE;
     md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index cca883f..e75cccf 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -125,7 +125,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,
     MMIOState *s = qemu_mallocz(sizeof(MMIOState));
     int mem1, mem2;
 
-    ide_init2(&s->bus, hd0, hd1, irq);
+    ide_init2_with_non_qdev_drives(&s->bus, hd0, hd1, irq);
 
     s->shift = shift;
 
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 4fa3851..dad6e86 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -135,8 +135,8 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
     ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
     ide_init_ioport(&d->bus[1], 0x170, 0x376);
 
-    ide_init2(&d->bus[0], NULL, NULL, isa_reserve_irq(14));
-    ide_init2(&d->bus[1], NULL, NULL, isa_reserve_irq(15));
+    ide_init2(&d->bus[0], isa_reserve_irq(14));
+    ide_init2(&d->bus[1], isa_reserve_irq(15));
     return 0;
 }
 
-- 
1.6.6.1

  parent reply	other threads:[~2010-06-01 18:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-01 18:32 [Qemu-devel] [PATCH 00/14] Block-related fixes and cleanups Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 01/14] blockdev: Belatedly remove MAX_DRIVES Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 02/14] blockdev: Belatedly remove driveopts Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 03/14] usb: Remove unused usb_device_add() parameter is_hotplug Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 04/14] ide: Remove useless IDEDeviceInfo members unit, drive Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 05/14] ide: Remove redundant IDEState member conf Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 06/14] ide: Split ide_init1() off ide_init2() Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 07/14] ide: Change ide_init_drive() to require valid dinfo argument Markus Armbruster
2010-06-01 18:32 ` Markus Armbruster [this message]
2010-06-01 18:32 ` [Qemu-devel] [PATCH 09/14] qdev: New qdev_prop_set_string() Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 10/14] qdev: Don't leak string property value on hot unplug Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 11/14] ide: Turn drive serial into a qdev property ide-drive.serial Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 12/14] ide: Fix info qtree for ide-drive.ver Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 13/14] scsi: Turn drive serial into a qdev property scsi-disk.serial Markus Armbruster
2010-06-01 18:32 ` [Qemu-devel] [PATCH 14/14] scsi: Fix info qtree for scsi-disk.ver Markus Armbruster
2010-06-02 15:53 ` [Qemu-devel] Re: [PATCH 00/14] Block-related fixes and cleanups Kevin Wolf
  -- strict thread matches above, loose matches on Subject: below --
2010-05-28 13:38 [Qemu-devel] " Markus Armbruster
2010-05-28 13:38 ` [Qemu-devel] [PATCH 08/14] ide: Split non-qdev code off ide_init2() Markus Armbruster

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=1275417155-28244-9-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@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).