From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Xiao Guangrong" <guangrong.xiao@gmail.com>,
"Vadim Rozenfeld" <vrozenfe@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH v3 1/3] mc146818rtc: Simplify by reordering if() statement
Date: Thu, 24 Oct 2019 14:24:23 +0200 [thread overview]
Message-ID: <20191024122425.2483-2-philmd@redhat.com> (raw)
In-Reply-To: <20191024122425.2483-1-philmd@redhat.com>
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 --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)
--
2.21.0
next prev parent reply other threads:[~2019-10-24 13:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 12:24 [PATCH v3 0/3] mc146818rtc: fix timer interrupt reinjection Philippe Mathieu-Daudé
2019-10-24 12:24 ` Philippe Mathieu-Daudé [this message]
2019-10-24 12:24 ` [PATCH v3 2/3] mc146818rtc: Tidy up indentation Philippe Mathieu-Daudé
2019-10-24 13:01 ` Paolo Bonzini
2019-10-24 13:21 ` Philippe Mathieu-Daudé
2019-10-24 12:24 ` [PATCH v3 3/3] mc146818rtc: fix timer interrupt reinjection Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191024122425.2483-2-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=guangrong.xiao@gmail.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vrozenfe@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).