diff mbox series

[07/15] hw/timer/arm_timer: Extract arm_timer_reset()

Message ID 20230531203559.29140-8-philmd@linaro.org
State Superseded
Headers show
Series hw/timer/arm_timer: QOM'ify ARM_TIMER and correct sysbus/irq in ICP_PIT | expand

Commit Message

Philippe Mathieu-Daudé May 31, 2023, 8:35 p.m. UTC
Extract arm_timer_reset() before converting this model to QOM/QDev
in few commits. This will become our DeviceReset handler.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/timer/arm_timer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Peter Maydell June 8, 2023, 2:46 p.m. UTC | #1
On Wed, 31 May 2023 at 21:36, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Extract arm_timer_reset() before converting this model to QOM/QDev
> in few commits. This will become our DeviceReset handler.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/timer/arm_timer.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
> index 2cd8c99b4e..54318d0a57 100644
> --- a/hw/timer/arm_timer.c
> +++ b/hw/timer/arm_timer.c
> @@ -172,13 +172,18 @@ static const VMStateDescription vmstate_arm_timer = {
>      }
>  };
>
> +static void arm_timer_reset(ArmTimerState *s)
> +{
> +    s->control = TIMER_CTRL_IE;
> +}

Reset also should zero s->limit and s->int_level.
(in arm_timer_init() this was implicit in the g_new0()).)

thanks
-- PMM
Philippe Mathieu-Daudé July 4, 2023, 10:01 a.m. UTC | #2
On 8/6/23 16:46, Peter Maydell wrote:
> On Wed, 31 May 2023 at 21:36, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Extract arm_timer_reset() before converting this model to QOM/QDev
>> in few commits. This will become our DeviceReset handler.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/timer/arm_timer.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)


>> +static void arm_timer_reset(ArmTimerState *s)
>> +{
>> +    s->control = TIMER_CTRL_IE;
>> +}
> 
> Reset also should zero s->limit and s->int_level.
> (in arm_timer_init() this was implicit in the g_new0()).)

Oops I missed that, thanks!
diff mbox series

Patch

diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
index 2cd8c99b4e..54318d0a57 100644
--- a/hw/timer/arm_timer.c
+++ b/hw/timer/arm_timer.c
@@ -172,13 +172,18 @@  static const VMStateDescription vmstate_arm_timer = {
     }
 };
 
+static void arm_timer_reset(ArmTimerState *s)
+{
+    s->control = TIMER_CTRL_IE;
+}
+
 static ArmTimerState *arm_timer_init(uint32_t freq)
 {
     ArmTimerState *s;
 
     s = g_new0(ArmTimerState, 1);
     s->freq = freq;
-    s->control = TIMER_CTRL_IE;
+    arm_timer_reset(s);
 
     s->timer = ptimer_init(arm_timer_tick, s, PTIMER_POLICY_LEGACY);
     vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_arm_timer, s);