From: Karel Zak <kzak@redhat.com>
To: J William Piggott <elseifthen@gmx.com>
Cc: Andreas Henriksson <andreas@fatal.se>,
util-linux@vger.kernel.org,
Serge Schneider <serge@raspberrypi.org>
Subject: Re: hwclock's synchronize_to_clock_tick_rtc returns inconsistent values
Date: Mon, 20 Apr 2015 14:21:32 +0200 [thread overview]
Message-ID: <20150420122132.GB27969@ws.net.home> (raw)
In-Reply-To: <55344548.6050102@gmx.com>
On Sun, Apr 19, 2015 at 08:16:08PM -0400, J William Piggott wrote:
> > rc = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
> > ret = 1;
> > if (rc == -1)
> > warn(_("select() to %s to wait for clock tick
> > failed"),
> > rtc_dev_name);
> > else if (rc == 0 && debug)
> > printf(_("select() to %s to wait for clock
> > tick timed out"),
> > rtc_dev_name);
> > else
> > ret = 0;
> >
>
> Karel,
>
> The select time out still needs to return 1, so the debug test should
> have been a separate statement.
Yes, the debug (-D) should bot affect how this code works, but it
seems that hwclock.c:manipulate_clock() assumes return 2 after
time out and we already use "2" in busy wait version of the
synchronization.
> I don't have time to patch and test this right now, but I can do it
> later if you want?
See the patch below (note that patch also remove never used #ifdef
dead code).
diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c
index 78f42aa..3173591 100644
--- a/sys-utils/hwclock-rtc.c
+++ b/sys-utils/hwclock-rtc.c
@@ -280,18 +280,6 @@ static int synchronize_to_clock_tick_rtc(void)
rtc_dev_name);
ret = busywait_for_rtc_clock_tick(rtc_fd);
} else if (rc == 0) {
-#ifdef Wait_until_update_interrupt
- unsigned long dummy;
-
- /* this blocks until the next update interrupt */
- rc = read(rtc_fd, &dummy, sizeof(dummy));
- ret = 1;
- if (rc == -1)
- warn(_("read() to %s to wait for clock tick failed"),
- rtc_dev_name);
- else
- ret = 0;
-#else
/*
* Just reading rtc_fd fails on broken hardware: no
* update interrupt comes and a bootscript with a
@@ -310,15 +298,22 @@ static int synchronize_to_clock_tick_rtc(void)
tv.tv_usec = 0;
rc = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
ret = 1;
- if (rc == -1)
+
+ switch (rc) {
+ case -1: /* error */
warn(_("select() to %s to wait for clock tick failed"),
rtc_dev_name);
- else if (rc == 0 && debug)
- printf(_("select() to %s to wait for clock tick timed out"),
- rtc_dev_name);
- else
+ break;
+ case 0: /* timeout */
+ if (debug)
+ printf(_("select() to %s to wait for clock tick timed out"),
+ rtc_dev_name);
+ ret = 2;
+ break;
+ default: /* success */
ret = 0;
-#endif
+ break;
+ }
/* Turn off update interrupts */
rc = ioctl(rtc_fd, RTC_UIE_OFF, 0);
next prev parent reply other threads:[~2015-04-20 12:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 20:36 hwclock's synchronize_to_clock_tick_rtc returns inconsistent values Andreas Henriksson
2015-04-20 0:16 ` J William Piggott
2015-04-20 12:21 ` Karel Zak [this message]
2015-04-21 2:50 ` J William Piggott
2015-04-22 2:18 ` J William Piggott
2015-04-22 7:46 ` Karel Zak
2015-04-22 16:45 ` J William Piggott
2015-04-22 18:07 ` Andreas Henriksson
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=20150420122132.GB27969@ws.net.home \
--to=kzak@redhat.com \
--cc=andreas@fatal.se \
--cc=elseifthen@gmx.com \
--cc=serge@raspberrypi.org \
--cc=util-linux@vger.kernel.org \
/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