On 16/2/22 23:45, Bernhard Beschow wrote:
Now that gt64120_register() lost its pic parameter, there is an
opportunity to remove it. gt64120_register() is old style by wrapping
qdev API, and the new style is to use qdev directly. So take the
opportunity and modernize the code.

Suggested-by: BALATON Zoltan <bala...@eik.bme.hu>
Signed-off-by: Bernhard Beschow <shen...@gmail.com>
---
  hw/mips/gt64xxx_pci.c  | 21 ++++-----------------
  hw/mips/malta.c        | 13 ++++++++-----
  include/hw/mips/mips.h |  3 ---
  3 files changed, 12 insertions(+), 25 deletions(-)

  static void gt64120_pci_realize(PCIDevice *d, Error **errp)
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 13254dbc89..16fdaed3db 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -38,6 +38,7 @@
  #include "hw/mips/mips.h"
  #include "hw/mips/cpudevs.h"
  #include "hw/pci/pci.h"
+#include "hw/pci/pci_host.h"
  #include "qemu/log.h"
  #include "hw/mips/bios.h"
  #include "hw/ide.h"
@@ -1230,7 +1231,7 @@ void mips_malta_init(MachineState *machine)
      const size_t smbus_eeprom_size = 8 * 256;
      uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size);
      uint64_t kernel_entry, bootloader_run_addr;
-    PCIBus *pci_bus;
+    PCIHostState *phb;
      ISABus *isa_bus;
      qemu_irq cbus_irq, i8259_irq;
      I2CBus *smbus;
@@ -1390,7 +1391,9 @@ void mips_malta_init(MachineState *machine)
      stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
/* Northbridge */
-    pci_bus = gt64120_register();
+    dev = qdev_new("gt64120");
+    phb = PCI_HOST_BRIDGE(dev);
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);

Nice cleanup!

I might move the phb assignation afther the realize() for clarity
(usually we only set qdev properties between qdev_new and the
realize).

Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org>


Reply via email to