Skip to content

Expand oscillator stop flag (OSF) validity check to ds1341

Meagan Lloyd linux-rtc lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v1 Latest posting 2/22 patches 0 repliesNew
  2. v1 posting 1/22 patches 4 repliesApplied

Patches in v1 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2rtc: ds1307: remove clear of oscillator stop flag (OSF) in probedrivers/rtc/rtc-ds1307.c+1 -30 replies
2/2rtc: ds1307: handle oscillator stop flag (OSF) for ds1341drivers/rtc/rtc-ds1307.c+11 -00 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchRodolfo GiomettiTyler Hicks
1/2A-b R-b
2/2A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH RESEND 0/2] Expand oscillator stop flag (OSF) validity check to ds1341

We would like to use CONFIG_RTC_HCTOSYS to sync a supercapacitor-backed DS1342 RTC to the kernel time early in boot. An obstacle is that the sync in rtc_hctosys() is unconditional as long as rtc_read_time() succeeds and in some power loss situations, our RTC comes up with either an unpredictable future time or the default 01/01/00 from the datasheet. Syncing a future time, followed by an NTP sync would not be desired as it would result in a backwards time jump. The sync feature is useful in boot scenarios where power is maintained so syncing only when the RTC data is valid would allow us to make use of the feature.

The DS1342 has the oscillator stop flag (OSF) which is a status flag indicating that the oscillator stopped for a period of time. It can be set due to power loss. Some chip types in the ds1307 driver already use the OSF to determine whether .read_time should provide valid data or return -EINVAL. This patch series expands that handling to the ds1341 chip type (DS1341 and DS1342 share a datasheet).

These changes enable us to make use of CONFIG_RTC_HCTOSYS as they prevent the invalid time from getting synced to the kernel time. It will also prevent userspace programs from getting the invalid time as the fix cuts it off at the source - the .read_time function.

Meagan Lloyd (2):
rtc: ds1307: remove clear of oscillator stop flag (OSF) in probe
rtc: ds1307: handle oscillator stop flag (OSF) for ds1341

 drivers/rtc/rtc-ds1307.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494

Signature · 1 line
2.49.0