diff mbox series

[for-8.0,1/2] hw/input/ps2: Convert TYPE_PS2_DEVICE to 3-phase reset

Message ID 20221109170009.3498451-2-peter.maydell@linaro.org
State Superseded
Headers show
Series hw/input/ps2: Convert to 3-phase reset | expand

Commit Message

Peter Maydell Nov. 9, 2022, 5 p.m. UTC
Convert the parent class TYPE_PS2_DEVICE to 3-phase reset.  Note that
we need an 'exit' phase function as well as the usual 'hold' phase
function, because changing outbound IRQ line state is only permitted
in 'exit'.  (Strictly speaking it's not supposed to be done in a
legacy reset handler either, but you can often get away with it.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/input/ps2.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Philippe Mathieu-Daudé Nov. 9, 2022, 10:34 p.m. UTC | #1
On 9/11/22 18:00, Peter Maydell wrote:
> Convert the parent class TYPE_PS2_DEVICE to 3-phase reset.  Note that
> we need an 'exit' phase function as well as the usual 'hold' phase
> function, because changing outbound IRQ line state is only permitted
> in 'exit'.  (Strictly speaking it's not supposed to be done in a
> legacy reset handler either, but you can often get away with it.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/input/ps2.c | 14 +++++++++++---
>   1 file changed, 11 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Richard Henderson Nov. 10, 2022, 5:36 a.m. UTC | #2
On 11/10/22 04:00, Peter Maydell wrote:
> Convert the parent class TYPE_PS2_DEVICE to 3-phase reset.  Note that
> we need an 'exit' phase function as well as the usual 'hold' phase
> function, because changing outbound IRQ line state is only permitted
> in 'exit'.  (Strictly speaking it's not supposed to be done in a
> legacy reset handler either, but you can often get away with it.)
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/input/ps2.c | 14 +++++++++++---
>   1 file changed, 11 insertions(+), 3 deletions(-)

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

r~
diff mbox series

Patch

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 05cf7111e31..47a5d68e300 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -1001,12 +1001,18 @@  void ps2_write_mouse(PS2MouseState *s, int val)
     }
 }
 
-static void ps2_reset(DeviceState *dev)
+static void ps2_reset_hold(Object *obj)
 {
-    PS2State *s = PS2_DEVICE(dev);
+    PS2State *s = PS2_DEVICE(obj);
 
     s->write_cmd = -1;
     ps2_reset_queue(s);
+}
+
+static void ps2_reset_exit(Object *obj)
+{
+    PS2State *s = PS2_DEVICE(obj);
+
     ps2_lower_irq(s);
 }
 
@@ -1281,8 +1287,10 @@  static void ps2_init(Object *obj)
 static void ps2_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    dc->reset = ps2_reset;
+    rc->phases.hold = ps2_reset_hold;
+    rc->phases.exit = ps2_reset_exit;
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }