diff mbox series

[v3,1/3] mc146818rtc: Simplify by reordering if() statement

Message ID 20191024122425.2483-2-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series mc146818rtc: fix timer interrupt reinjection | expand

Commit Message

Philippe Mathieu-Daudé Oct. 24, 2019, 12:24 p.m. UTC
Reorder the if() statement, so further changes in this function
will be easier to read.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/timer/mc146818rtc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 6cb378751b..2b6371faac 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -203,7 +203,12 @@  periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
 
     period = rtc_periodic_clock_ticks(s);
 
-    if (period) {
+    if (!period) {
+        s->irq_coalesced = 0;
+        timer_del(s->periodic_timer);
+        return;
+    }
+
         /* compute 32 khz clock */
         cur_clock =
             muldiv64(current_time, RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND);
@@ -263,10 +268,6 @@  periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
         next_irq_clock = cur_clock + period - lost_clock;
         s->next_periodic_time = periodic_clock_to_ns(next_irq_clock) + 1;
         timer_mod(s->periodic_timer, s->next_periodic_time);
-    } else {
-        s->irq_coalesced = 0;
-        timer_del(s->periodic_timer);
-    }
 }
 
 static void rtc_periodic_timer(void *opaque)