From owner-svn-src-all@FreeBSD.ORG Mon Mar 23 21:16:22 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B62510656EB; Mon, 23 Mar 2009 21:16:22 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2BF268FC0C; Mon, 23 Mar 2009 21:16:22 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2NLGMK5021875; Mon, 23 Mar 2009 21:16:22 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2NLGMAx021874; Mon, 23 Mar 2009 21:16:22 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <200903232116.n2NLGMAx021874@svn.freebsd.org> From: Jung-uk Kim Date: Mon, 23 Mar 2009 21:16:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190337 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2009 21:16:27 -0000 Author: jkim Date: Mon Mar 23 21:16:21 2009 New Revision: 190337 URL: http://svn.freebsd.org/changeset/base/190337 Log: Clean up MI inittodr(9) and kill noop code. It was derived from i386 version long ago but never resync'ed again. Originally, i386 version compared the current time from realtime clock with time_second (which was just `time' in the old days). When this MI version was written, it was wrongly compared against `base' AND never used because of a bug (typo?) in the code. This check was killed in i386 version when home-rolled calendaric calculation was removed. Now, we just remove the code here as well to make the code simpler. Modified: head/sys/kern/subr_rtc.c Modified: head/sys/kern/subr_rtc.c ============================================================================== --- head/sys/kern/subr_rtc.c Mon Mar 23 20:53:50 2009 (r190336) +++ head/sys/kern/subr_rtc.c Mon Mar 23 21:16:21 2009 (r190337) @@ -109,44 +109,36 @@ clock_register(device_t dev, long res) / void inittodr(time_t base) { - struct timespec diff, ref, ts; + struct timespec ref, ts; int error; - if (base) { - ref.tv_sec = base; - ref.tv_nsec = 0; - tc_setclock(&ref); - } - if (clock_dev == NULL) { printf("warning: no time-of-day clock registered, system time " "will not be set accurately\n"); - return; + goto wrong_time; } /* XXX: We should poll all registered RTCs in case of failure */ error = CLOCK_GETTIME(clock_dev, &ts); if (error != 0 && error != EINVAL) { printf("warning: clock_gettime failed (%d), the system time " "will not be set accurately\n", error); - return; + goto wrong_time; } if (error == EINVAL || ts.tv_sec < 0) { - printf("Invalid time in real time clock.\n"); - printf("Check and reset the date immediately!\n"); + printf("Invalid time in real time clock.\n" + "Check and reset the date immediately!\n"); + goto wrong_time; } ts.tv_sec += utc_offset(); + tc_setclock(&ts); + return; - if (timespeccmp(&ref, &ts, >)) { - diff = ref; - timespecsub(&ref, &ts); - } else { - diff = ts; - timespecsub(&diff, &ref); - } - if (ts.tv_sec >= 2) { - /* badly off, adjust it */ - tc_setclock(&ts); +wrong_time: + if (base > 0) { + ref.tv_sec = base; + ref.tv_nsec = 0; + tc_setclock(&ref); } }