From owner-svn-src-head@freebsd.org Tue Jan 16 23:14:13 2018 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 964E8EBEE05; Tue, 16 Jan 2018 23:14:13 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5522A71FBF; Tue, 16 Jan 2018 23:14:13 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 534422719D; Tue, 16 Jan 2018 23:14:12 +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 w0GNECvn024367; Tue, 16 Jan 2018 23:14:12 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0GNECt7024366; Tue, 16 Jan 2018 23:14:12 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801162314.w0GNECt7024366@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 16 Jan 2018 23:14:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328068 - head/sys/x86/isa X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/x86/isa X-SVN-Commit-Revision: 328068 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.25 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: Tue, 16 Jan 2018 23:14:13 -0000 Author: ian Date: Tue Jan 16 23:14:12 2018 New Revision: 328068 URL: https://svnweb.freebsd.org/changeset/base/328068 Log: Move some code around and rename a couple variables; no functional changes. The static atrtc_set() function was called only from clock_settime(), so just move its contents entirely into clock_settime() and delete atrtc_set(). Rename the struct bcd_clocktime variables from 'ct' to 'bct'. I had originally wanted to emphasize how identical the clocktime and bcd_clocktime structs were, but things evolved to the point where the structs are not at all identical anymore, so now emphasizing the difference seems better. Modified: head/sys/x86/isa/atrtc.c Modified: head/sys/x86/isa/atrtc.c ============================================================================== --- head/sys/x86/isa/atrtc.c Tue Jan 16 23:08:25 2018 (r328067) +++ head/sys/x86/isa/atrtc.c Tue Jan 16 23:14:12 2018 (r328068) @@ -169,39 +169,6 @@ atrtc_restore(void) rtcin(RTC_INTR); } -static void -atrtc_set(struct timespec *ts) -{ - struct bcd_clocktime ct; - - clock_ts_to_bcd(ts, &ct, false); - - mtx_lock(&atrtc_time_lock); - RTC_LOCK; - - /* Disable RTC updates and interrupts. */ - rtcout_locked(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR); - - /* Write all the time registers. */ - rtcout_locked(RTC_SEC, ct.sec); - rtcout_locked(RTC_MIN, ct.min); - rtcout_locked(RTC_HRS, ct.hour); - rtcout_locked(RTC_WDAY, ct.dow + 1); - rtcout_locked(RTC_DAY, ct.day); - rtcout_locked(RTC_MONTH, ct.mon); - rtcout_locked(RTC_YEAR, ct.year & 0xff); -#ifdef USE_RTC_CENTURY - rtcout_locked(RTC_CENTURY, ct.year >> 8); -#endif - - /* Re-enable RTC updates and interrupts. */ - rtcout_locked(RTC_STATUSB, rtc_statusb); - rtcin_locked(RTC_INTR); - - RTC_UNLOCK; - mtx_unlock(&atrtc_time_lock); -} - /********************************************************************** * RTC driver for subr_rtc */ @@ -348,15 +315,44 @@ atrtc_resume(device_t dev) static int atrtc_settime(device_t dev __unused, struct timespec *ts) { + struct bcd_clocktime bct; - atrtc_set(ts); + clock_ts_to_bcd(ts, &bct, false); + + mtx_lock(&atrtc_time_lock); + RTC_LOCK; + + /* Disable RTC updates and interrupts. */ + rtcout_locked(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR); + + /* Write all the time registers. */ + rtcout_locked(RTC_SEC, bct.sec); + rtcout_locked(RTC_MIN, bct.min); + rtcout_locked(RTC_HRS, bct.hour); + rtcout_locked(RTC_WDAY, bct.dow + 1); + rtcout_locked(RTC_DAY, bct.day); + rtcout_locked(RTC_MONTH, bct.mon); + rtcout_locked(RTC_YEAR, bct.year & 0xff); +#ifdef USE_RTC_CENTURY + rtcout_locked(RTC_CENTURY, bct.year >> 8); +#endif + + /* + * Re-enable RTC updates and interrupts. + */ + rtcout_locked(RTC_STATUSB, rtc_statusb); + rtcin_locked(RTC_INTR); + + RTC_UNLOCK; + mtx_unlock(&atrtc_time_lock); + return (0); } static int atrtc_gettime(device_t dev, struct timespec *ts) { - struct bcd_clocktime ct; + struct bcd_clocktime bct; /* Look if we have a RTC present and the time is valid */ if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) { @@ -376,22 +372,22 @@ atrtc_gettime(device_t dev, struct timespec *ts) continue; critical_enter(); RTC_LOCK; - ct.sec = rtcin_locked(RTC_SEC); - ct.min = rtcin_locked(RTC_MIN); - ct.hour = rtcin_locked(RTC_HRS); - ct.day = rtcin_locked(RTC_DAY); - ct.mon = rtcin_locked(RTC_MONTH); - ct.year = rtcin_locked(RTC_YEAR); + bct.sec = rtcin_locked(RTC_SEC); + bct.min = rtcin_locked(RTC_MIN); + bct.hour = rtcin_locked(RTC_HRS); + bct.day = rtcin_locked(RTC_DAY); + bct.mon = rtcin_locked(RTC_MONTH); + bct.year = rtcin_locked(RTC_YEAR); #ifdef USE_RTC_CENTURY - ct.year |= rtcin_locked(RTC_CENTURY) << 8; + bct.year |= rtcin_locked(RTC_CENTURY) << 8; #endif RTC_UNLOCK; critical_exit(); mtx_unlock(&atrtc_time_lock); /* dow is unused in timespec conversion and we have no nsec info. */ - ct.dow = 0; - ct.nsec = 0; - return (clock_bcd_to_ts(&ct, ts, false)); + bct.dow = 0; + bct.nsec = 0; + return (clock_bcd_to_ts(&bct, ts, false)); } static device_method_t atrtc_methods[] = {