Move npcm7xx_timer_reached_zero call out of npcm7xx_timer_pause
authorHavard Skinnemoen <hskinnemoen@google.com>
Fri, 23 Oct 2020 21:06:33 +0000 (14:06 -0700)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 27 Oct 2020 10:44:07 +0000 (10:44 +0000)
This allows us to reuse npcm7xx_timer_pause for the watchdog timer.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/timer/npcm7xx_timer.c

index 5703e43d4049763c1094d54bd49b77ce969b7256..2df9e3e4969f28eaa72382b7f0cdaacafc71279f 100644 (file)
@@ -157,9 +157,6 @@ static void npcm7xx_timer_pause(NPCM7xxTimer *t)
     timer_del(&t->qtimer);
     now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     t->remaining_ns = t->expires_ns - now;
-    if (t->remaining_ns <= 0) {
-        npcm7xx_timer_reached_zero(t);
-    }
 }
 
 /*
@@ -239,6 +236,9 @@ static void npcm7xx_timer_write_tcsr(NPCM7xxTimer *t, uint32_t new_tcsr)
         } else {
             t->tcsr &= ~NPCM7XX_TCSR_CACT;
             npcm7xx_timer_pause(t);
+            if (t->remaining_ns <= 0) {
+                npcm7xx_timer_reached_zero(t);
+            }
         }
     }
 }