[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 1/2] hw/char/serial: Expose SerialState::irq as QDev GPIO
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 1/2] hw/char/serial: Expose SerialState::irq as QDev GPIO |
Date: |
Sat, 11 Jan 2025 00:04:17 +0100 |
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(-)
diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c
index 3d913891dcb..2e755eaf440 100644
--- a/hw/char/serial-isa.c
+++ b/hw/char/serial-isa.c
@@ -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);
diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c
index 7578e863cfe..54b6224f4da 100644
--- a/hw/char/serial-pci-multi.c
+++ b/hw/char/serial-pci-multi.c
@@ -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);
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 6659cef5d4b..4291bfc4e7f 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -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);
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 70044e14a0f..cdff29ccee2 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -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);
--
2.47.1