在 Linux 中,读取基于 I2C 的 RTC 时,谁来处理计数器结转情况?

in Linux, when reading an I2C-based RTC, who handles counter carry-over conditions?

从基于 I2C 的 RTC 读取多个字节时,似乎有可能在读取每个字节时,其中一个值可能会递增。

例如,如果时间是:

2014-12-3123:59:59

当您读取此值时,时间可能会滚动到

2015-01-0100:00:00

所以你可能真的会读到:

2015-01-0123:59:59

(取决于您首先阅读的值)。

那么,确保可靠读取是 rtc 驱动程序的责任吗?

阅读 DS1337 的数据表,第 9 页指出:

When reading or writing the time and date registers, secondary (user) buffers are used to prevent errors when the internal registers update. When reading the time and date registers, the user buffers are synchronized to the internal registers on any start or stop and when the register pointer rolls over to zero.

因此,如果读取(或写入)发生在单个 I2C 操作中(没有回绕),RTC 设备保证一切都是同步的。

[我没有检查任何其他设备的数据表,但我认为它们的工作原理都相似。]