qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 7/7] hw/mips/gt64xxx_pci: Resolve gt64120_register()


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v3 7/7] hw/mips/gt64xxx_pci: Resolve gt64120_register()
Date: Thu, 17 Feb 2022 00:13:22 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

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 <balaton@eik.bme.hu>
Signed-off-by: Bernhard Beschow <shentey@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é <f4bug@amsat.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]