@@ -76,8 +76,8 @@ static void serial_isa_realizefn(DeviceState *dev, Error **errp)
}
index++;
- s->irq = isa_get_irq(isadev, isa->isairq);
qdev_realize(DEVICE(s), NULL, errp);
+ qdev_connect_gpio_out(DEVICE(s), 0, isa_get_irq(isadev, isa->isairq));
qdev_set_legacy_instance_id(dev, isa->iobase, 3);
memory_region_init_io(&s->io, OBJECT(isa), &serial_io_ops, s, "serial", 8);
@@ -110,7 +110,7 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
multi_serial_pci_exit(dev);
return;
}
- s->irq = pci->irqs[i];
+ qdev_connect_gpio_out(DEVICE(s), 0, pci->irqs[i]);
pci->name[i] = g_strdup_printf("uart #%zu", i + 1);
memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s,
pci->name[i], 8);
@@ -52,10 +52,10 @@ static void serial_pci_realize(PCIDevice *dev, Error **errp)
if (!qdev_realize(DEVICE(s), NULL, errp)) {
return;
}
+ qdev_connect_gpio_out(DEVICE(s), 0, pci_allocate_irq(&pci->dev));
pci->dev.config[PCI_CLASS_PROG] = pci->prog_if;
pci->dev.config[PCI_INTERRUPT_PIN] = 0x01;
- s->irq = pci_allocate_irq(&pci->dev);
memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, "serial", 8);
pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
@@ -923,6 +923,8 @@ static void serial_realize(DeviceState *dev, Error **errp)
{
SerialState *s = SERIAL(dev);
+ qdev_init_gpio_out(dev, &s->irq, 1);
+
s->modem_status_poll = timer_new_ns(QEMU_CLOCK_VIRTUAL, (QEMUTimerCB *) serial_update_msl, s);
s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, (QEMUTimerCB *) fifo_timeout_int, s);
Use the QDev GPIO API to set the TYPE_SERIAL output IRQ, this way we don't have to explicitly set the SerialState::irq pointer before realizing the object. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/char/serial-isa.c | 2 +- hw/char/serial-pci-multi.c | 2 +- hw/char/serial-pci.c | 2 +- hw/char/serial.c | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-)