Date: Mon, 23 Mar 2009 21:16:22 +0000 (UTC) From: Jung-uk Kim <jkim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r190337 - head/sys/kern Message-ID: <200903232116.n2NLGMAx021874@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903232116.n2NLGMAx021874>