Patchwork [22/26] Add pci_cirrus_vga_{save/load} functions, then remove vga.pci_dev use

login
register
mail settings
Submitter Juan Quintela
Date Aug. 24, 2009, 4:42 p.m.
Message ID <6af7aacfdace3c84449d2d5ec413205b4778e898.1251131364.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/31987/
State Superseded
Headers show

Comments

Juan Quintela - Aug. 24, 2009, 4:42 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/cirrus_vga.c |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

Patch

diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 9bcaa96..16cc054 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3021,9 +3021,6 @@  static void cirrus_vga_save(QEMUFile *f, void *opaque)
 {
     CirrusVGAState *s = opaque;

-    if (s->vga.pci_dev)
-        pci_device_save(s->vga.pci_dev, f);
-
     qemu_put_be32s(f, &s->vga.latch);
     qemu_put_8s(f, &s->vga.sr_index);
     qemu_put_buffer(f, s->vga.sr, 256);
@@ -3062,17 +3059,10 @@  static void cirrus_vga_save(QEMUFile *f, void *opaque)
 static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
 {
     CirrusVGAState *s = opaque;
-    int ret;

     if (version_id > 2)
         return -EINVAL;

-    if (s->vga.pci_dev && version_id >= 2) {
-        ret = pci_device_load(s->vga.pci_dev, f);
-        if (ret < 0)
-            return ret;
-    }
-
     qemu_get_be32s(f, &s->vga.latch);
     qemu_get_8s(f, &s->vga.sr_index);
     qemu_get_buffer(f, s->vga.sr, 256);
@@ -3115,6 +3105,31 @@  static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }

+static void pci_cirrus_vga_save(QEMUFile *f, void *opaque)
+{
+    PCICirrusVGAState *s = opaque;
+
+    pci_device_save(&s->dev, f);
+    cirrus_vga_save(f, &s->cirrus_vga);
+}
+
+static int pci_cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
+{
+    PCICirrusVGAState *s = opaque;
+    int ret;
+
+    if (version_id > 2)
+        return -EINVAL;
+
+    if (version_id >= 2) {
+        ret = pci_device_load(&s->dev, f);
+        if (ret < 0)
+            return ret;
+    }
+
+    return cirrus_vga_load(f, &s->cirrus_vga, version_id);
+}
+
 /***************************************
  *
  *  initialize
@@ -3231,7 +3246,6 @@  static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci)

     qemu_register_reset(cirrus_reset, s);
     cirrus_reset(s);
-    register_savevm("cirrus_vga", 0, 2, cirrus_vga_save, cirrus_vga_load, s);
 }

 /***************************************
@@ -3251,6 +3265,7 @@  void isa_cirrus_vga_init(void)
     s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate,
                                      s->vga.screen_dump, s->vga.text_update,
                                      &s->vga);
+    register_savevm("cirrus_vga", 0, 2, cirrus_vga_save, cirrus_vga_load, s);
     /* XXX ISA-LFB support */
 }

@@ -3312,7 +3327,6 @@  static void pci_cirrus_vga_initfn(PCIDevice *dev)
      /* setup VGA */
      vga_common_init(&s->vga, VGA_RAM_SIZE);
      cirrus_init_common(s, device_id, 1);
-     s->vga.pci_dev = dev;
      s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate,
                                       s->vga.screen_dump, s->vga.text_update,
                                       &s->vga);
@@ -3334,6 +3348,7 @@  static void pci_cirrus_vga_initfn(PCIDevice *dev)
          pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
                           PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map);
      }
+     register_savevm("cirrus_vga", 0, 2, pci_cirrus_vga_save, pci_cirrus_vga_load, d);
      /* XXX: ROM BIOS */
 }