diff mbox series

[1/3] hw/misc/mac_via: Make generic via_irq_request() from via1_irq_request()

Message ID 20201013204927.3660030-2-f4bug@amsat.org
State New
Headers show
Series hw/misc/mac_via: Factor generic via_irq_request() out | expand

Commit Message

Philippe Mathieu-Daudé Oct. 13, 2020, 8:49 p.m. UTC
Rewrite via1_irq_request() as generic via_irq_request().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/misc/mac_via.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
index 6db62dab7db..9e64c2521fc 100644
--- a/hw/misc/mac_via.c
+++ b/hw/misc/mac_via.c
@@ -324,6 +324,20 @@  static void via1_one_second_update(MOS6522Q800VIA1State *v1s)
     }
 }
 
+static void via_irq_request(void *opaque, int irq, int level)
+{
+    MOS6522State *s = MOS6522(opaque);
+    MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(s);
+
+    if (level) {
+        s->ifr |= 1 << irq;
+    } else {
+        s->ifr &= ~(1 << irq);
+    }
+
+    mdc->update_irq(s);
+}
+
 static void via1_VBL(void *opaque)
 {
     MOS6522Q800VIA1State *v1s = opaque;
@@ -348,21 +362,6 @@  static void via1_one_second(void *opaque)
     via1_one_second_update(v1s);
 }
 
-static void via1_irq_request(void *opaque, int irq, int level)
-{
-    MOS6522Q800VIA1State *v1s = opaque;
-    MOS6522State *s = MOS6522(v1s);
-    MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(s);
-
-    if (level) {
-        s->ifr |= 1 << irq;
-    } else {
-        s->ifr &= ~(1 << irq);
-    }
-
-    mdc->update_irq(s);
-}
-
 static void via2_irq_request(void *opaque, int irq, int level)
 {
     MOS6522Q800VIA2State *v2s = opaque;
@@ -1195,7 +1194,7 @@  static void mos6522_q800_via1_reset(DeviceState *dev)
 
 static void mos6522_q800_via1_init(Object *obj)
 {
-    qdev_init_gpio_in_named(DEVICE(obj), via1_irq_request, "via1-irq",
+    qdev_init_gpio_in_named(DEVICE(obj), via_irq_request, "via1-irq",
                             VIA1_IRQ_NB);
 }