Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 May 2010 10:15:37 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r208295 - stable/8/sys/kern
Message-ID:  <201005191015.o4JAFb8s042348@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Wed May 19 10:15:37 2010
New Revision: 208295
URL: http://svn.freebsd.org/changeset/base/208295

Log:
  MFC r207359,207362: kern_ntptime: abstract time error check into a
  function

Modified:
  stable/8/sys/kern/kern_ntptime.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/kern/kern_ntptime.c
==============================================================================
--- stable/8/sys/kern/kern_ntptime.c	Wed May 19 09:32:59 2010	(r208294)
+++ stable/8/sys/kern/kern_ntptime.c	Wed May 19 10:15:37 2010	(r208295)
@@ -198,22 +198,11 @@ static long pps_errcnt;			/* calibration
 static void ntp_init(void);
 static void hardupdate(long offset);
 static void ntp_gettime1(struct ntptimeval *ntvp);
+static int ntp_is_time_error(void);
 
-static void
-ntp_gettime1(struct ntptimeval *ntvp)
+static int
+ntp_is_time_error(void)
 {
-	struct timespec atv;	/* nanosecond time */
-
-	GIANT_REQUIRED;
-
-	nanotime(&atv);
-	ntvp->time.tv_sec = atv.tv_sec;
-	ntvp->time.tv_nsec = atv.tv_nsec;
-	ntvp->maxerror = time_maxerror;
-	ntvp->esterror = time_esterror;
-	ntvp->tai = time_tai;
-	ntvp->time_state = time_state;
-
 	/*
 	 * Status word error decode. If any of these conditions occur,
 	 * an error is returned, instead of the status word. Most
@@ -243,6 +232,27 @@ ntp_gettime1(struct ntptimeval *ntvp)
 	 */
 	    (time_status & STA_PPSFREQ &&
 	    time_status & (STA_PPSWANDER | STA_PPSERROR)))
+		return (1);
+
+	return (0);
+}
+
+static void
+ntp_gettime1(struct ntptimeval *ntvp)
+{
+	struct timespec atv;	/* nanosecond time */
+
+	GIANT_REQUIRED;
+
+	nanotime(&atv);
+	ntvp->time.tv_sec = atv.tv_sec;
+	ntvp->time.tv_nsec = atv.tv_nsec;
+	ntvp->maxerror = time_maxerror;
+	ntvp->esterror = time_esterror;
+	ntvp->tai = time_tai;
+	ntvp->time_state = time_state;
+
+	if (ntp_is_time_error())
 		ntvp->time_state = TIME_ERROR;
 }
 
@@ -442,21 +452,11 @@ ntp_adjtime(struct thread *td, struct nt
 	if (error)
 		goto done2;
 
-	/*
-	 * Status word error decode. See comments in
-	 * ntp_gettime() routine.
-	 */
-	if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) ||
-	    (time_status & (STA_PPSFREQ | STA_PPSTIME) &&
-	    !(time_status & STA_PPSSIGNAL)) ||
-	    (time_status & STA_PPSTIME &&
-	    time_status & STA_PPSJITTER) ||
-	    (time_status & STA_PPSFREQ &&
-	    time_status & (STA_PPSWANDER | STA_PPSERROR))) {
+	if (ntp_is_time_error())
 		td->td_retval[0] = TIME_ERROR;
-	} else {
+	else
 		td->td_retval[0] = time_state;
-	}
+
 done2:
 	mtx_unlock(&Giant);
 	return (error);



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