[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/54] ps2: improve function prototypes in ps2.c and ps2.h
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 06/54] ps2: improve function prototypes in ps2.c and ps2.h |
Date: |
Fri, 24 Jun 2022 14:40:21 +0100 |
With the latest changes it is now possible to improve some of the function
prototypes in ps2.c and ps.h to use the appropriate PS2KbdState or
PS2MouseState type instead of being a void opaque.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Helge Deller <deller@gmx.de>
---
hw/input/ps2.c | 22 +++++++++-------------
include/hw/input/ps2.h | 8 ++++----
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index f4bad9876a..3a770f3b78 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -581,12 +581,11 @@ static void ps2_reset_keyboard(PS2KbdState *s)
ps2_set_ledstate(s, 0);
}
-void ps2_write_keyboard(void *opaque, int val)
+void ps2_write_keyboard(PS2KbdState *s, int val)
{
- PS2KbdState *s = (PS2KbdState *)opaque;
PS2State *ps2 = PS2_DEVICE(s);
- trace_ps2_write_keyboard(opaque, val);
+ trace_ps2_write_keyboard(s, val);
ps2_cqueue_reset(ps2);
switch (ps2->write_cmd) {
default:
@@ -675,10 +674,9 @@ void ps2_write_keyboard(void *opaque, int val)
* 1 = translated scancodes (used by qemu internally).
*/
-void ps2_keyboard_set_translation(void *opaque, int mode)
+void ps2_keyboard_set_translation(PS2KbdState *s, int mode)
{
- PS2KbdState *s = (PS2KbdState *)opaque;
- trace_ps2_keyboard_set_translation(opaque, mode);
+ trace_ps2_keyboard_set_translation(s, mode);
s->translate = mode;
}
@@ -857,20 +855,18 @@ static void ps2_mouse_sync(DeviceState *dev)
}
}
-void ps2_mouse_fake_event(void *opaque)
+void ps2_mouse_fake_event(PS2MouseState *s)
{
- PS2MouseState *s = opaque;
- trace_ps2_mouse_fake_event(opaque);
+ trace_ps2_mouse_fake_event(s);
s->mouse_dx++;
- ps2_mouse_sync(opaque);
+ ps2_mouse_sync(DEVICE(s));
}
-void ps2_write_mouse(void *opaque, int val)
+void ps2_write_mouse(PS2MouseState *s, int val)
{
- PS2MouseState *s = (PS2MouseState *)opaque;
PS2State *ps2 = PS2_DEVICE(s);
- trace_ps2_write_mouse(opaque, val);
+ trace_ps2_write_mouse(s, val);
switch (ps2->write_cmd) {
default:
case -1:
diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h
index 7f2c3f6090..1a3321d77e 100644
--- a/include/hw/input/ps2.h
+++ b/include/hw/input/ps2.h
@@ -92,8 +92,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE)
/* ps2.c */
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
-void ps2_write_mouse(void *, int val);
-void ps2_write_keyboard(void *, int val);
+void ps2_write_mouse(PS2MouseState *s, int val);
+void ps2_write_keyboard(PS2KbdState *s, int val);
uint32_t ps2_read_data(PS2State *s);
void ps2_queue_noirq(PS2State *s, int b);
void ps2_raise_irq(PS2State *s);
@@ -101,8 +101,8 @@ void ps2_queue(PS2State *s, int b);
void ps2_queue_2(PS2State *s, int b1, int b2);
void ps2_queue_3(PS2State *s, int b1, int b2, int b3);
void ps2_queue_4(PS2State *s, int b1, int b2, int b3, int b4);
-void ps2_keyboard_set_translation(void *opaque, int mode);
-void ps2_mouse_fake_event(void *opaque);
+void ps2_keyboard_set_translation(PS2KbdState *s, int mode);
+void ps2_mouse_fake_event(PS2MouseState *s);
int ps2_queue_empty(PS2State *s);
#endif /* HW_PS2_H */
--
2.30.2
- [PATCH v2 00/54] PS2 device QOMification - part 1, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 01/54] ps2: checkpatch fixes, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 02/54] ps2: QOMify PS2State, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 03/54] ps2: QOMify PS2KbdState, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 04/54] ps2: QOMify PS2MouseState, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 05/54] ps2: move QOM type definitions from ps2.c to ps2.h, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 06/54] ps2: improve function prototypes in ps2.c and ps2.h,
Mark Cave-Ayland <=
- [PATCH v2 07/54] ps2: introduce PS2DeviceClass, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 08/54] ps2: implement ps2_reset() for the PS2_DEVICE QOM type based upon ps2_common_reset(), Mark Cave-Ayland, 2022/06/24
- [PATCH v2 09/54] ps2: remove duplicate setting of scancode_set in ps2_kbd_init(), Mark Cave-Ayland, 2022/06/24
- [PATCH v2 11/54] ps2: implement ps2_mouse_realize() and use it to register ps2_mouse_handler, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 10/54] ps2: implement ps2_kbd_realize() and use it to register ps2_keyboard_handler, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 12/54] ps2: don't use vmstate_register() in ps2_kbd_init(), Mark Cave-Ayland, 2022/06/24
- [PATCH v2 13/54] ps2: don't use vmstate_register() in ps2_mouse_init(), Mark Cave-Ayland, 2022/06/24
- [PATCH v2 14/54] pl050: checkpatch fixes, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 15/54] pl050: split pl050_update_irq() into separate pl050_set_irq() and pl050_update_irq() functions, Mark Cave-Ayland, 2022/06/24
- [PATCH v2 16/54] lasips2: spacing fixes, Mark Cave-Ayland, 2022/06/24