diff mbox series

[3/5] hw/i386/pc: Un-inline i8254_pit_init()

Message ID 20230215174353.37097-4-philmd@linaro.org
State New
Headers show
Series hw/timer/i8254: Un-inline and simplify IRQs | expand

Commit Message

Philippe Mathieu-Daudé Feb. 15, 2023, 5:43 p.m. UTC
pc_basic_device_init() is the single caller of i8254_pit_init()
with a non-NULL 'alt_irq' argument. Open-code i8254_pit_init()
by direclty calling i8254_pit_create().

To confirm all other callers pass a NULL 'alt_irq', add an
assertion in i8254_pit_init().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/pc.c             | 10 +++++-----
 include/hw/timer/i8254.h |  5 ++---
 2 files changed, 7 insertions(+), 8 deletions(-)

Comments

Richard Henderson Feb. 15, 2023, 6:58 p.m. UTC | #1
On 2/15/23 07:43, Philippe Mathieu-Daudé wrote:
> pc_basic_device_init() is the single caller of i8254_pit_init()
> with a non-NULL 'alt_irq' argument. Open-code i8254_pit_init()
> by direclty calling i8254_pit_create().
> 
> To confirm all other callers pass a NULL 'alt_irq', add an
> assertion in i8254_pit_init().
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/i386/pc.c             | 10 +++++-----
>   include/hw/timer/i8254.h |  5 ++---
>   2 files changed, 7 insertions(+), 8 deletions(-)

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

r~
diff mbox series

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 79297a6ecd..fe95f6e9f2 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1258,8 +1258,7 @@  void pc_basic_device_init(struct PCMachineState *pcms,
 {
     int i;
     DeviceState *hpet = NULL;
-    int pit_isa_irq = 0;
-    qemu_irq pit_alt_irq = NULL;
+    qemu_irq pit_irq;
     qemu_irq rtc_irq = NULL;
     ISADevice *pit = NULL;
     MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
@@ -1301,9 +1300,10 @@  void pc_basic_device_init(struct PCMachineState *pcms,
         for (i = 0; i < GSI_NUM_PINS; i++) {
             sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]);
         }
-        pit_isa_irq = -1;
-        pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
+        pit_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
         rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
+    } else {
+        pit_irq = isa_bus_get_irq(isa_bus, 0);
     }
     *rtc_state = mc146818_rtc_init(isa_bus, 2000, rtc_irq);
 
@@ -1314,7 +1314,7 @@  void pc_basic_device_init(struct PCMachineState *pcms,
         if (kvm_pit_in_kernel()) {
             pit = kvm_pit_init(isa_bus, 0x40);
         } else {
-            pit = i8254_pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
+            pit = i8254_pit_create(isa_bus, 0x40, pit_irq);
         }
         if (hpet) {
             /* connect PIT to output control line of the HPET */
diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h
index a0843cae07..0d837f3f41 100644
--- a/include/hw/timer/i8254.h
+++ b/include/hw/timer/i8254.h
@@ -59,9 +59,8 @@  ISADevice *i8254_pit_create(ISABus *bus, int iobase, qemu_irq irq_in);
 static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq,
                                         qemu_irq alt_irq)
 {
-    return i8254_pit_create(bus, base, isa_irq >= 0
-                                       ? isa_bus_get_irq(bus, isa_irq)
-                                       : alt_irq);
+    assert(isa_irq == 0 && alt_irq == NULL);
+    return i8254_pit_create(bus, base, isa_bus_get_irq(bus, 0));
 }
 
 static inline ISADevice *kvm_pit_init(ISABus *bus, int base)