Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Jul 2017 15:24:40 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321795 - head/sys/dev/iicbus
Message-ID:  <201707311524.v6VFOeDl096311@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Mon Jul 31 15:24:40 2017
New Revision: 321795
URL: https://svnweb.freebsd.org/changeset/base/321795

Log:
  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.

Modified:
  head/sys/dev/iicbus/ds1307.c

Modified: head/sys/dev/iicbus/ds1307.c
==============================================================================
--- head/sys/dev/iicbus/ds1307.c	Mon Jul 31 15:23:19 2017	(r321794)
+++ head/sys/dev/iicbus/ds1307.c	Mon Jul 31 15:24:40 2017	(r321795)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707311524.v6VFOeDl096311>