Skip to contentSkip to conversation

rtc: clarify the RTC offset correction

PATCH Applied Russell King 3 participants 4 messages Sep 29, 2017 – Oct 25, 2017 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: clarify the RTC offset correction

The RTC offset correction documentation is not very clear about the exact relationship between "offset" and the effect it has on the RTC. Supplement the documentation with an equation giving the relationship.

---
 drivers/rtc/interface.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/rtc/interface.c +4 -0
index 8cec9a02c0b8..045e0a72d14b 100644
@@ -1004,6 +1004,10 @@ int rtc_read_offset(struct rtc_device *rtc, long *offset)
  * to compensate for differences in the actual clock rate due to temperature,
  * the crystal, capacitor, etc.
  *
+ * The adjustment applied is as follows:
+ *   t = t0 * (1 + offset * 1e-9)
+ * where t0 is the measured length of 1 RTC second with offset = 0
+ *
  * Kernel interface to adjust an rtc clock offset.
  * Return 0 on success, or a negative number on error.
  * If the rtc offset is not setable (or not implemented), return -EINVAL
Signature · 1 line
2.7.4
#1 lore raw

Hi,

Quoted 14 lines · Russell King

The RTC offset correction documentation is not very clear about the exact relationship between "offset" and the effect it has on the RTC. Supplement the documentation with an equation giving the relationship.

---
 drivers/rtc/interface.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/rtc/interface.c +0 -0
index 8cec9a02c0b8..045e0a72d14b 100644

drivers/rtc/interface.c int rtc_read_offset(struct rtc_device *rtc, long *offset) · line 1010

Quoted 7 lines
drivers/rtc/interface.c +4 -0
@@ -1004,6 +1004,10 @@ int rtc_read_offset(struct rtc_device *rtc, long *offset)
  * to compensate for differences in the actual clock rate due to temperature,
  * the crystal, capacitor, etc.
  *
+ * The adjustment applied is as follows:
+ *   t = t0 * (1 + offset * 1e-9)
+ * where t0 is the measured length of 1 RTC second with offset = 0
+ *

More documentation is available in Documentation/rtc.txt. Maybe it is worth having the formula in both.

Quoted 6 lines
drivers/rtc/interface.c +0 -0
  * Kernel interface to adjust an rtc clock offset.
  * Return 0 on success, or a negative number on error.
  * If the rtc offset is not setable (or not implemented), return -EINVAL
Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#2 lore raw
Quoted 12 lines · Alexandre Belloni

Hi,

Quoted 9 lines · Russell King

The RTC offset correction documentation is not very clear about the exact relationship between "offset" and the effect it has on the RTC. Supplement the documentation with an equation giving the relationship.

---
 drivers/rtc/interface.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 15 lines

drivers/rtc/interface.c int rtc_read_offset(struct rtc_device *rtc, long *offset) · line 1010

Quoted 12 lines
drivers/rtc/interface.c +4 -0
index 8cec9a02c0b8..045e0a72d14b 100644
@@ -1004,6 +1004,10 @@ int rtc_read_offset(struct rtc_device *rtc, long *offset)
  * to compensate for differences in the actual clock rate due to temperature,
  * the crystal, capacitor, etc.
  *
+ * The adjustment applied is as follows:
+ *   t = t0 * (1 + offset * 1e-9)
+ * where t0 is the measured length of 1 RTC second with offset = 0
+ *

More documentation is available in Documentation/rtc.txt. Maybe it is worth having the formula in both.

That sounds like a nightmare - stuff should be documented in detail in one place and only one place, otherwise we risk the two sets of identical documentation going out of sync. A better idea would be to reference the detailed documentation - which I guess would be easier if rtc.txt were converted to a .rst file?

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
#3 lore raw
In reply to Russell King
Quoted 9 lines · Russell King

The RTC offset correction documentation is not very clear about the exact relationship between "offset" and the effect it has on the RTC. Supplement the documentation with an equation giving the relationship.

---
 drivers/rtc/interface.c | 4 ++++
 1 file changed, 4 insertions(+)

Applied, thanks.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com