Author: avg
Date: Wed May 19 10:29:37 2010
New Revision: 208296
URL: http://svn.freebsd.org/changeset/base/208296

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

Modified:
  stable/7/sys/kern/kern_ntptime.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/kern/kern_ntptime.c
==============================================================================
--- stable/7/sys/kern/kern_ntptime.c    Wed May 19 10:15:37 2010        
(r208295)
+++ stable/7/sys/kern/kern_ntptime.c    Wed May 19 10:29:37 2010        
(r208296)
@@ -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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to