diff mbox series

[RFC,5/7] hw/ide/via: Configure IDE bus IRQs after realization

Message ID 20240209123226.32576-6-philmd@linaro.org
State New
Headers show
Series hw/qdev: Split 'wiring' phase from 'realize' | expand

Commit Message

Philippe Mathieu-Daudé Feb. 9, 2024, 12:32 p.m. UTC
We shouldn't call qdev_get_gpio_in() on unrealized devices.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
Ideally we should rework the current IDE bus model to really
use QOM and not globals. Left for later.
---
 hw/ide/via.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 3f3c484253..caf1b69bd4 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -226,6 +226,15 @@  static void via_ide_realize(PCIDevice *dev, Error **errp)
     qdev_init_gpio_in(ds, via_ide_set_irq, ARRAY_SIZE(d->bus));
     for (i = 0; i < ARRAY_SIZE(d->bus); i++) {
         ide_bus_init(&d->bus[i], sizeof(d->bus[i]), ds, i, MAX_IDE_DEVS);
+    }
+}
+
+static void via_ide_wire(DeviceState *dev)
+{
+    PCIIDEState *d = PCI_IDE(dev);
+    DeviceState *ds = DEVICE(dev);
+
+    for (unsigned i = 0; i < ARRAY_SIZE(d->bus); i++) {
         ide_bus_init_output_irq(&d->bus[i], qdev_get_gpio_in(ds, i));
 
         bmdma_init(&d->bus[i], &d->bmdma[i], d);
@@ -249,6 +258,7 @@  static void via_ide_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
+    dc->wire = via_ide_wire;
     dc->reset = via_ide_reset;
     dc->vmsd = &vmstate_ide_pci;
     /* Reason: only works as function of VIA southbridge */