Re: [RFC][PATCH - 1/12] NTP cleanup: Move NTP code into ntp.c

2005-07-20 Thread john stultz
On Mon, 2005-07-18 at 13:42 +0200, Pavel Machek wrote:
> Hi!
> > Any comments or feedback would be greatly appreciated.
> > +#ifdef CONFIG_TIME_INTERPOLATION
> > +void time_interpolator_update(long delta_nsec);
> > +#else
> > +#define time_interpolator_update(x)
> 
> do {} while (0) is safer...

Applied. 

> > +   result = time_state;   /* mostly `TIME_OK' */
> > +
> > +   /* Save for later - semantics of adjtime is to return old value */
> > +   save_adjust = time_next_adjust ? time_next_adjust : time_adjust;
> > +
> > +#if 0  /* STA_CLOCKERR is never set yet */
> > +   time_status &= ~STA_CLOCKERR;   /* reset STA_CLOCKERR */
> > +#endif
> 
> Please remove deleted code completely.

Done in a later patch, but good point, I'll kill it in the first one. 


Thanks for the review and feedback! 
-john


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH - 1/12] NTP cleanup: Move NTP code into ntp.c

2005-07-20 Thread john stultz
On Mon, 2005-07-18 at 13:42 +0200, Pavel Machek wrote:
 Hi!
  Any comments or feedback would be greatly appreciated.
  +#ifdef CONFIG_TIME_INTERPOLATION
  +void time_interpolator_update(long delta_nsec);
  +#else
  +#define time_interpolator_update(x)
 
 do {} while (0) is safer...

Applied. 

  +   result = time_state;   /* mostly `TIME_OK' */
  +
  +   /* Save for later - semantics of adjtime is to return old value */
  +   save_adjust = time_next_adjust ? time_next_adjust : time_adjust;
  +
  +#if 0  /* STA_CLOCKERR is never set yet */
  +   time_status = ~STA_CLOCKERR;   /* reset STA_CLOCKERR */
  +#endif
 
 Please remove deleted code completely.

Done in a later patch, but good point, I'll kill it in the first one. 


Thanks for the review and feedback! 
-john


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH - 1/12] NTP cleanup: Move NTP code into ntp.c

2005-07-18 Thread Pavel Machek
Hi!

>   This patch moves the generic NTP code from time.c and timer.c into
> ntp.c. It makes most of the NTP variables static providing more
> understandable interfaces like ntp_synced() and ntp_clear(). 
>   
> Since some of the newly made static variables are used in arch generic
> code, this patch alone will not compile. Thus this patch requires part 2
> of the series which fixes the arch specific uses of the newly static
> variables.
> 
> Any comments or feedback would be greatly appreciated.
> 
> thanks
> -john
> 

> diff --git a/kernel/ntp.c b/kernel/ntp.c
> new file mode 100644
> --- /dev/null
> +++ b/kernel/ntp.c
> @@ -0,0 +1,490 @@
> +/
> +* linux/kernel/ntp.c
> +*
> +* NTP state machine and time scaling code.
> +*
> +* Code moved from kernel/time.c and kernel/timer.c
> +* Please see those files for original copyrights.
> +*
> +* This program is free software; you can redistribute it and/or modify
> +* it under the terms of the GNU General Public License as published by
> +* the Free Software Foundation; either version 2 of the License, or
> +* (at your option) any later version.
> +*
> +* This program is distributed in the hope that it will be useful,
> +* but WITHOUT ANY WARRANTY; without even the implied warranty of
> +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +* GNU General Public License for more details.
> +*
> +* You should have received a copy of the GNU General Public License
> +* along with this program; if not, write to the Free Software
> +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> +*
> +* Notes:
> +*
> +* Hopefully you should never have to understand or touch
> +* any of the code below. but don't let that keep you from trying!
 ~~~ should be "," ?

> +* This code is loosely based on David Mills' RFC 1589 and its
> +* updates. Please see the following for more details:
> +*  http://www.eecis.udel.edu/~mills/database/rfc/rfc1589.txt
> +*  http://www.eecis.udel.edu/~mills/database/reports/kern/kernb.pdf
> +*
> +* NOTE:  To simplify the code, we do not implement any of
> +* the PPS code, as the code that uses it never was merged.
> +* [EMAIL PROTECTED]
> +*
> +*/
> +
> +#include 
> +#include 
> +#include 
> +
> +#ifdef CONFIG_TIME_INTERPOLATION
> +void time_interpolator_update(long delta_nsec);
> +#else
> +#define time_interpolator_update(x)

do {} while (0) is safer...

> + result = time_state;   /* mostly `TIME_OK' */
> +
> + /* Save for later - semantics of adjtime is to return old value */
> + save_adjust = time_next_adjust ? time_next_adjust : time_adjust;
> +
> +#if 0/* STA_CLOCKERR is never set yet */
> + time_status &= ~STA_CLOCKERR;   /* reset STA_CLOCKERR */
> +#endif

Please remove deleted code completely.

> +/**
> + * ntp_synced - Returns 1 if the NTP status is not UNSYNC
> + *
> + */
> +int ntp_synced(void)
> +{
> + return !(time_status & STA_UNSYNC);
> +}

Should this be inline in header somewhere?

Pavel
-- 
teflon -- maybe it is a trademark, but it should not be.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH - 1/12] NTP cleanup: Move NTP code into ntp.c

2005-07-18 Thread Pavel Machek
Hi!

   This patch moves the generic NTP code from time.c and timer.c into
 ntp.c. It makes most of the NTP variables static providing more
 understandable interfaces like ntp_synced() and ntp_clear(). 
   
 Since some of the newly made static variables are used in arch generic
 code, this patch alone will not compile. Thus this patch requires part 2
 of the series which fixes the arch specific uses of the newly static
 variables.
 
 Any comments or feedback would be greatly appreciated.
 
 thanks
 -john
 

 diff --git a/kernel/ntp.c b/kernel/ntp.c
 new file mode 100644
 --- /dev/null
 +++ b/kernel/ntp.c
 @@ -0,0 +1,490 @@
 +/
 +* linux/kernel/ntp.c
 +*
 +* NTP state machine and time scaling code.
 +*
 +* Code moved from kernel/time.c and kernel/timer.c
 +* Please see those files for original copyrights.
 +*
 +* This program is free software; you can redistribute it and/or modify
 +* it under the terms of the GNU General Public License as published by
 +* the Free Software Foundation; either version 2 of the License, or
 +* (at your option) any later version.
 +*
 +* This program is distributed in the hope that it will be useful,
 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +* GNU General Public License for more details.
 +*
 +* You should have received a copy of the GNU General Public License
 +* along with this program; if not, write to the Free Software
 +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 +*
 +* Notes:
 +*
 +* Hopefully you should never have to understand or touch
 +* any of the code below. but don't let that keep you from trying!
 ~~~ should be , ?

 +* This code is loosely based on David Mills' RFC 1589 and its
 +* updates. Please see the following for more details:
 +*  http://www.eecis.udel.edu/~mills/database/rfc/rfc1589.txt
 +*  http://www.eecis.udel.edu/~mills/database/reports/kern/kernb.pdf
 +*
 +* NOTE:  To simplify the code, we do not implement any of
 +* the PPS code, as the code that uses it never was merged.
 +* [EMAIL PROTECTED]
 +*
 +*/
 +
 +#include linux/ntp.h
 +#include linux/jiffies.h
 +#include linux/errno.h
 +
 +#ifdef CONFIG_TIME_INTERPOLATION
 +void time_interpolator_update(long delta_nsec);
 +#else
 +#define time_interpolator_update(x)

do {} while (0) is safer...

 + result = time_state;   /* mostly `TIME_OK' */
 +
 + /* Save for later - semantics of adjtime is to return old value */
 + save_adjust = time_next_adjust ? time_next_adjust : time_adjust;
 +
 +#if 0/* STA_CLOCKERR is never set yet */
 + time_status = ~STA_CLOCKERR;   /* reset STA_CLOCKERR */
 +#endif

Please remove deleted code completely.

 +/**
 + * ntp_synced - Returns 1 if the NTP status is not UNSYNC
 + *
 + */
 +int ntp_synced(void)
 +{
 + return !(time_status  STA_UNSYNC);
 +}

Should this be inline in header somewhere?

Pavel
-- 
teflon -- maybe it is a trademark, but it should not be.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC][PATCH - 1/12] NTP cleanup: Move NTP code into ntp.c

2005-07-15 Thread john stultz
All,
This patch moves the generic NTP code from time.c and timer.c into
ntp.c. It makes most of the NTP variables static providing more
understandable interfaces like ntp_synced() and ntp_clear(). 

Since some of the newly made static variables are used in arch generic
code, this patch alone will not compile. Thus this patch requires part 2
of the series which fixes the arch specific uses of the newly static
variables.

Any comments or feedback would be greatly appreciated.

thanks
-john


linux-2.6.13-rc3_timeofday-ntp-part1_B4.patch

diff --git a/include/linux/ntp.h b/include/linux/ntp.h
new file mode 100644
--- /dev/null
+++ b/include/linux/ntp.h
@@ -0,0 +1,28 @@
+/*  linux/include/linux/ntp.h
+ *
+ *  This file NTP state machine accessor functions.
+ */
+
+#ifndef _LINUX_NTP_H
+#define _LINUX_NTP_H
+#include 
+#include 
+#include 
+
+/* NTP state machine interfaces */
+int ntp_advance(void);
+int ntp_adjtimex(struct timex*);
+void second_overflow(void);
+void ntp_clear(void);
+int ntp_synced(void);
+
+/* Due to ppc64 having its own NTP  code,
+ * these variables cannot be made static just yet
+ */
+extern int tickadj;
+extern long time_offset;
+extern long time_freq;
+extern long time_adjust;
+extern long time_constant;
+
+#endif
diff --git a/include/linux/timex.h b/include/linux/timex.h
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -226,39 +226,6 @@ struct timex {
  */
 extern unsigned long tick_usec;/* USER_HZ period (usec) */
 extern unsigned long tick_nsec;/* ACTHZ  period (nsec) 
*/
-extern int tickadj;/* amount of adjustment per tick */
-
-/*
- * phase-lock loop variables
- */
-extern int time_state; /* clock status */
-extern int time_status;/* clock synchronization status bits */
-extern long time_offset;   /* time adjustment (us) */
-extern long time_constant; /* pll time constant */
-extern long time_tolerance;/* frequency tolerance (ppm) */
-extern long time_precision;/* clock precision (us) */
-extern long time_maxerror; /* maximum error */
-extern long time_esterror; /* estimated error */
-
-extern long time_freq; /* frequency offset (scaled ppm) */
-extern long time_reftime;  /* time at last adjustment (s) */
-
-extern long time_adjust;   /* The amount of adjtime left */
-extern long time_next_adjust;  /* Value for time_adjust at next tick */
-
-/* interface variables pps->timer interrupt */
-extern long pps_offset;/* pps time offset (us) */
-extern long pps_jitter;/* time dispersion (jitter) (us) */
-extern long pps_freq;  /* frequency offset (scaled ppm) */
-extern long pps_stabil;/* frequency dispersion (scaled ppm) */
-extern long pps_valid; /* pps signal watchdog counter */
-
-/* interface variables pps->adjtimex */
-extern int pps_shift;  /* interval duration (s) (shift) */
-extern long pps_jitcnt;/* jitter limit exceeded */
-extern long pps_calcnt;/* calibration intervals */
-extern long pps_errcnt;/* calibration errors */
-extern long pps_stbcnt;/* stability limit exceeded */
 
 #ifdef CONFIG_TIME_INTERPOLATION
 
diff --git a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -7,7 +7,7 @@ obj-y = sched.o fork.o exec_domain.o
sysctl.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o pid.o \
rcupdate.o intermodule.o extable.o params.o posix-timers.o \
-   kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o
+   kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o ntp.o
 
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
diff --git a/kernel/ntp.c b/kernel/ntp.c
new file mode 100644
--- /dev/null
+++ b/kernel/ntp.c
@@ -0,0 +1,490 @@
+/
+* linux/kernel/ntp.c
+*
+* NTP state machine and time scaling code.
+*
+* Code moved from kernel/time.c and kernel/timer.c
+* Please see those files for original copyrights.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+* Notes:
+*
+* Hopefully you should never have to understand or 

[RFC][PATCH - 1/12] NTP cleanup: Move NTP code into ntp.c

2005-07-15 Thread john stultz
All,
This patch moves the generic NTP code from time.c and timer.c into
ntp.c. It makes most of the NTP variables static providing more
understandable interfaces like ntp_synced() and ntp_clear(). 

Since some of the newly made static variables are used in arch generic
code, this patch alone will not compile. Thus this patch requires part 2
of the series which fixes the arch specific uses of the newly static
variables.

Any comments or feedback would be greatly appreciated.

thanks
-john


linux-2.6.13-rc3_timeofday-ntp-part1_B4.patch

diff --git a/include/linux/ntp.h b/include/linux/ntp.h
new file mode 100644
--- /dev/null
+++ b/include/linux/ntp.h
@@ -0,0 +1,28 @@
+/*  linux/include/linux/ntp.h
+ *
+ *  This file NTP state machine accessor functions.
+ */
+
+#ifndef _LINUX_NTP_H
+#define _LINUX_NTP_H
+#include linux/types.h
+#include linux/time.h
+#include linux/timex.h
+
+/* NTP state machine interfaces */
+int ntp_advance(void);
+int ntp_adjtimex(struct timex*);
+void second_overflow(void);
+void ntp_clear(void);
+int ntp_synced(void);
+
+/* Due to ppc64 having its own NTP  code,
+ * these variables cannot be made static just yet
+ */
+extern int tickadj;
+extern long time_offset;
+extern long time_freq;
+extern long time_adjust;
+extern long time_constant;
+
+#endif
diff --git a/include/linux/timex.h b/include/linux/timex.h
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -226,39 +226,6 @@ struct timex {
  */
 extern unsigned long tick_usec;/* USER_HZ period (usec) */
 extern unsigned long tick_nsec;/* ACTHZ  period (nsec) 
*/
-extern int tickadj;/* amount of adjustment per tick */
-
-/*
- * phase-lock loop variables
- */
-extern int time_state; /* clock status */
-extern int time_status;/* clock synchronization status bits */
-extern long time_offset;   /* time adjustment (us) */
-extern long time_constant; /* pll time constant */
-extern long time_tolerance;/* frequency tolerance (ppm) */
-extern long time_precision;/* clock precision (us) */
-extern long time_maxerror; /* maximum error */
-extern long time_esterror; /* estimated error */
-
-extern long time_freq; /* frequency offset (scaled ppm) */
-extern long time_reftime;  /* time at last adjustment (s) */
-
-extern long time_adjust;   /* The amount of adjtime left */
-extern long time_next_adjust;  /* Value for time_adjust at next tick */
-
-/* interface variables pps-timer interrupt */
-extern long pps_offset;/* pps time offset (us) */
-extern long pps_jitter;/* time dispersion (jitter) (us) */
-extern long pps_freq;  /* frequency offset (scaled ppm) */
-extern long pps_stabil;/* frequency dispersion (scaled ppm) */
-extern long pps_valid; /* pps signal watchdog counter */
-
-/* interface variables pps-adjtimex */
-extern int pps_shift;  /* interval duration (s) (shift) */
-extern long pps_jitcnt;/* jitter limit exceeded */
-extern long pps_calcnt;/* calibration intervals */
-extern long pps_errcnt;/* calibration errors */
-extern long pps_stbcnt;/* stability limit exceeded */
 
 #ifdef CONFIG_TIME_INTERPOLATION
 
diff --git a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -7,7 +7,7 @@ obj-y = sched.o fork.o exec_domain.o
sysctl.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o pid.o \
rcupdate.o intermodule.o extable.o params.o posix-timers.o \
-   kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o
+   kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o ntp.o
 
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
diff --git a/kernel/ntp.c b/kernel/ntp.c
new file mode 100644
--- /dev/null
+++ b/kernel/ntp.c
@@ -0,0 +1,490 @@
+/
+* linux/kernel/ntp.c
+*
+* NTP state machine and time scaling code.
+*
+* Code moved from kernel/time.c and kernel/timer.c
+* Please see those files for original copyrights.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+* Notes:
+*
+* Hopefully you