Patchwork [09/38] ahci: reclaim memory in instance_finalize instead of exit

login
register
mail settings
Submitter Paolo Bonzini
Date Sept. 3, 2013, 12:33 p.m.
Message ID <1378211609-16121-10-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/272229/
State New
Headers show

Comments

Paolo Bonzini - Sept. 3, 2013, 12:33 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/ide/ahci.c |  2 +-
 hw/ide/ahci.h |  2 +-
 hw/ide/ich.c  | 12 ++++++++----
 3 files changed, 10 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index bba150f..8f1d37b 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1185,7 +1185,7 @@  void ahci_init(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
     }
 }
 
-void ahci_uninit(AHCIState *s)
+void ahci_instance_finalize(AHCIState *s)
 {
     memory_region_destroy(&s->mem);
     memory_region_destroy(&s->idp);
diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h
index 20e412c..d1d483c 100644
--- a/hw/ide/ahci.h
+++ b/hw/ide/ahci.h
@@ -347,7 +347,7 @@  typedef struct NCQFrame {
 } QEMU_PACKED NCQFrame;
 
 void ahci_init(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports);
-void ahci_uninit(AHCIState *s);
+void ahci_instance_finalize(AHCIState *s);
 
 void ahci_reset(AHCIState *s);
 
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index bff952b..e4f6416 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -140,11 +140,14 @@  static int pci_ich9_ahci_init(PCIDevice *dev)
 
 static void pci_ich9_uninit(PCIDevice *dev)
 {
-    struct AHCIPCIState *d;
-    d = ICH_AHCI(dev);
-
     msi_uninit(dev);
-    ahci_uninit(&d->ahci);
+}
+
+static void pci_ich9_instance_finalize(Object *obj)
+{
+    struct AHCIPCIState *d = ICH_AHCI(obj);
+
+    ahci_instance_finalize(&d->ahci);
 }
 
 static void ich_ahci_class_init(ObjectClass *klass, void *data)
@@ -168,6 +171,7 @@  static const TypeInfo ich_ahci_info = {
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(AHCIPCIState),
     .class_init    = ich_ahci_class_init,
+    .instance_finalize = pci_ich9_instance_finalize,
 };
 
 static void ich_ahci_register_types(void)