Check the clock-halted flag every time the clock is read, not just once

at startup.  The flag stays set until the clock is loaded with good time,
so we need to keep saying the time is invalid until that happens.
This commit is contained in:
ian 2017-07-31 15:24:40 +00:00
parent c2a28dc66d
commit 7a634438e9

View File

@ -328,6 +328,10 @@ ds1307_gettime(device_t dev, struct timespec *ts)
return (error);
}
/* If the clock halted, we don't have good data. */
if (data[DS1307_SECS] & DS1307_SECS_CH)
return (EINVAL);
/* If chip is in AM/PM mode remember that. */
if (data[DS1307_HOUR] & DS1307_HOUR_USE_AMPM) {
sc->sc_use_ampm = true;