diff mbox series

[8/8] hw/mips/fuloong2e: Open code bonito_init()

Message ID 20230105130710.49264-9-philmd@linaro.org
State New
Headers show
Series hw/pci-host/bonito: Housekeeping | expand

Commit Message

Philippe Mathieu-Daudé Jan. 5, 2023, 1:07 p.m. UTC
This helper is trivial and is called once, directly open-code it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/mips/fuloong2e.c    |  6 +++++-
 hw/pci-host/bonito.c   | 15 ---------------
 include/hw/mips/mips.h |  3 ---
 3 files changed, 5 insertions(+), 19 deletions(-)

Comments

Richard Henderson Jan. 6, 2023, 7:16 p.m. UTC | #1
On 1/5/23 05:07, Philippe Mathieu-Daudé wrote:
> This helper is trivial and is called once, directly open-code it.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/mips/fuloong2e.c    |  6 +++++-
>   hw/pci-host/bonito.c   | 15 ---------------
>   include/hw/mips/mips.h |  3 ---
>   3 files changed, 5 insertions(+), 19 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index 34befa5dd5..f41e19dc3f 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -32,6 +32,7 @@ 
 #include "hw/mips/bootloader.h"
 #include "hw/mips/cpudevs.h"
 #include "hw/pci/pci.h"
+#include "hw/pci-host/bonito.h"
 #include "hw/loader.h"
 #include "hw/ide/pci.h"
 #include "hw/qdev-properties.h"
@@ -292,7 +293,10 @@  static void mips_fuloong2e_init(MachineState *machine)
     cpu_mips_clock_init(cpu);
 
     /* North bridge, Bonito --> IP2 */
-    pci_bus = bonito_init((qemu_irq *)&(env->irq[2]));
+    dev = qdev_new(TYPE_BONITO_PCI_HOST_BRIDGE);
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[2]);
+    pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
 
     /* South bridge -> IP5 */
     pci_dev = pci_create_simple_multifunction(pci_bus,
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index df61b051b0..ca5fa2a155 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -44,7 +44,6 @@ 
 #include "qemu/error-report.h"
 #include "hw/pci/pci.h"
 #include "hw/irq.h"
-#include "hw/mips/mips.h"
 #include "hw/pci-host/bonito.h"
 #include "hw/pci/pci_host.h"
 #include "migration/vmstate.h"
@@ -750,20 +749,6 @@  static void bonito_pci_realize(PCIDevice *dev, Error **errp)
     pci_set_byte(dev->config + PCI_MAX_LAT, 0x00);
 }
 
-PCIBus *bonito_init(qemu_irq *pic)
-{
-    DeviceState *dev;
-    PCIHostState *phb;
-
-    dev = qdev_new(TYPE_BONITO_PCI_HOST_BRIDGE);
-    phb = PCI_HOST_BRIDGE(dev);
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
-
-    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, *pic);
-
-    return phb->bus;
-}
-
 static void bonito_pci_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h
index 101799f7d3..4d2db99952 100644
--- a/include/hw/mips/mips.h
+++ b/include/hw/mips/mips.h
@@ -9,9 +9,6 @@ 
 
 #include "exec/memory.h"
 
-/* bonito.c */
-PCIBus *bonito_init(qemu_irq *pic);
-
 /* rc4030.c */
 typedef struct rc4030DMAState *rc4030_dma;
 void rc4030_dma_read(void *dma, uint8_t *buf, int len);