simplify i440fx initialization by eliminating
i440fx_init_memory_mappings().

Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp>
---
 hw/pc.h       |    2 +-
 hw/pc_piix.c  |    8 +-------
 hw/piix_pci.c |   15 ++++++---------
 3 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/hw/pc.h b/hw/pc.h
index feb8a7a..38a0952 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -175,7 +175,7 @@ int pcspk_audio_init(qemu_irq *pic);
 struct PCII440FXState;
 typedef struct PCII440FXState PCII440FXState;
 
-PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq 
*pic, ram_addr_t ram_size);
+PCIBus *i440fx_init(int *piix_devfn, qemu_irq *pic, ram_addr_t ram_size);
 void i440fx_init_memory_mappings(PCII440FXState *d);
 
 /* piix4.c */
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index a85214b..43fac55 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -74,7 +74,6 @@ static void pc_init1(ram_addr_t ram_size,
     int i;
     ram_addr_t below_4g_mem_size, above_4g_mem_size;
     PCIBus *pci_bus;
-    PCII440FXState *i440fx_state;
     int piix3_devfn = -1;
     qemu_irq *cpu_irq;
     qemu_irq *isa_irq;
@@ -106,10 +105,9 @@ static void pc_init1(ram_addr_t ram_size,
     isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
 
     if (pci_enabled) {
-        pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, ram_size);
+        pci_bus = i440fx_init(&piix3_devfn, isa_irq, ram_size);
     } else {
         pci_bus = NULL;
-        i440fx_state = NULL;
         isa_bus_new(NULL);
     }
     isa_bus_irqs(isa_irq);
@@ -166,10 +164,6 @@ static void pc_init1(ram_addr_t ram_size,
         smbus_eeprom_init(smbus, 8, NULL, 0);
     }
 
-    if (i440fx_state) {
-        i440fx_init_memory_mappings(i440fx_state);
-    }
-
     if (pci_enabled) {
         pc_pci_device_init(pci_bus);
     }
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 4bcbce6..a668a31 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -84,11 +84,6 @@ static void i440fx_set_smm(int val, void *arg)
     smram_set_smm(&d->pam, val, d->dev.config[I440FX_SMRAM]);
 }
 
-void i440fx_init_memory_mappings(PCII440FXState *d)
-{
-    pam_init_memory_mappings(&d->pam);
-}
-
 static void i440fx_write_config(PCIDevice *dev,
                                 uint32_t address, uint32_t val, int len)
 {
@@ -164,15 +159,17 @@ static int i440fx_initfn(PCIDevice *dev)
     d->dev.config[I440FX_SMRAM] = 0x02;
 
     cpu_smm_register(&i440fx_set_smm, d);
+    pam_init_memory_mappings(&d->pam);
     return 0;
 }
 
-PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq 
*pic, ram_addr_t ram_size)
+PCIBus *i440fx_init(int *piix3_devfn, qemu_irq *pic, ram_addr_t ram_size)
 {
     DeviceState *dev;
     PCIBus *b;
     PCIDevice *d;
     I440FXState *s;
+    PCII440FXState *i440fx_state;
     PIIX3State *piix3;
 
     dev = qdev_create(NULL, "i440FX-pcihost");
@@ -182,20 +179,20 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int 
*piix3_devfn, qemu_irq *
     qdev_init_nofail(dev);
 
     d = pci_create_simple(b, 0, "i440FX");
-    *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d);
+    i440fx_state = DO_UPCAST(PCII440FXState, dev, d);
 
     piix3 = DO_UPCAST(PIIX3State, dev,
                       pci_create_simple_multifunction(b, -1, true, "PIIX3"));
     piix3->pic = pic;
     pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, 4);
-    (*pi440fx_state)->piix3 = piix3;
+    i440fx_state->piix3 = piix3;
 
     *piix3_devfn = piix3->dev.devfn;
 
     ram_size = ram_size / 8 / 1024 / 1024;
     if (ram_size > 255)
         ram_size = 255;
-    (*pi440fx_state)->dev.config[0x57]=ram_size;
+    i440fx_state->dev.config[0x57] = ram_size;
 
     return b;
 }
-- 
1.7.1.1


Reply via email to