From owner-svn-src-head@freebsd.org Mon Jul 31 15:24:42 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 07C99DB0FCC; Mon, 31 Jul 2017 15:24:42 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C67207F324; Mon, 31 Jul 2017 15:24:41 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6VFOenq096312; Mon, 31 Jul 2017 15:24:40 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6VFOeDl096311; Mon, 31 Jul 2017 15:24:40 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201707311524.v6VFOeDl096311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Mon, 31 Jul 2017 15:24:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321795 - head/sys/dev/iicbus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/iicbus X-SVN-Commit-Revision: 321795 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jul 2017 15:24:42 -0000 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;