Re: [PATCH 8/9] RFC: rtc: hctosys: support rtc_read_timeval() forhigh precision clocks

From: John Stultz
Date: Fri Jun 14 2013 - 15:21:06 EST

On 06/14/2013 09:52 AM, Alexander Holler wrote:
Some RTCs do provide a higher precision than seconds. Add support for them
by trying rtc_read_timeval() before using rtc_read_time() to get the time
in the hctosys mechanism.

+ rc = rtc_read_timeval(rtc, &tv);
+ if (rc || (!tv.tv_sec && !tv.tv_usec)) {
+ rc = rtc_read_time(rtc, &now);
+ if (unlikely(rc)) {
+ dev_err(rtc->dev.parent,
+ "rtc core: error reading time from RTC: %d\n",
+ rc);
+ return;
+ }
+ rtc_tm_to_time(&now, &ts.tv_sec);
+ ts.tv_nsec = NSEC_PER_SEC >> 1;
+ } else {
+ rtc_time_to_tm(tv.tv_sec, &now);
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec*NSEC_PER_USEC;

Yea, this sort of fallback logic should be centralized in the RTC layer rather then in the individual users.

Might be easiest to modify the rtc_read_timeval() interface to try the ops->read_timeval() operation and do the fallback to rtc_read_time() internally.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at