Skip to contentSkip to conversation

kernel/time.c: possible cleanups

PATCH In review Adrian Bunk 3 participants 3 messages Dec 12, 2004 – Dec 14, 2004 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/time.c: possible cleanups

The patch below contains some possible cleanups.

I don't claim it's correct, but since all these variables are never changed it doesn't make a difference.

diffstat output:

 include/linux/timex.h |    8 --------
 kernel/time.c         |   23 ++++++-----------------
 2 files changed, 6 insertions(+), 25 deletions(-)
include/linux/timex.h renamed from include/linux/timex.h.old +0 -8
@@ -249,19 +249,11 @@
 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
 
 #define TIME_SOURCE_CPU 0
kernel/time.c renamed from kernel/time.c.old +6 -17
@@ -197,7 +197,6 @@
 	return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
 }
 
-long pps_offset;		/* pps time offset (us) */
 long pps_jitter = MAXTIME;	/* time dispersion (jitter) (us) */
 
 long pps_freq;			/* frequency offset (scaled ppm) */
@@ -205,16 +204,6 @@
 
 long pps_valid = PPS_VALID;	/* pps signal watchdog counter */
 
-int pps_shift = PPS_SHIFT;	/* interval duration (s) (shift) */
-
-long pps_jitcnt;		/* jitter limit exceeded */
-long pps_calcnt;		/* calibration intervals */
-long pps_errcnt;		/* calibration errors */
-long pps_stbcnt;		/* stability limit exceeded */
-
-/* hook for a loadable hardpps kernel module */
-void (*hardpps_ptr)(struct timeval *);
-
 /* adjtimex mainly allows reading (and writing, if superuser) of
  * kernel time-keeping variables. used by xntpd.
  */
@@ -302,7 +291,7 @@
 		else if ( time_status & (STA_PLL | STA_PPSTIME) ) {
 		    ltemp = (time_status & (STA_PPSTIME | STA_PPSSIGNAL)) ==
 		            (STA_PPSTIME | STA_PPSSIGNAL) ?
-		            pps_offset : txc->offset;
+		            0 : txc->offset;
 
 		    /*
 		     * Scale the phase adjustment and
@@ -390,12 +379,12 @@
 	txc->tick	   = tick_usec;
 	txc->ppsfreq	   = pps_freq;
 	txc->jitter	   = pps_jitter >> PPS_AVG;
-	txc->shift	   = pps_shift;
+	txc->shift	   = PPS_SHIFT;
 	txc->stabil	   = pps_stabil;
-	txc->jitcnt	   = pps_jitcnt;
-	txc->calcnt	   = pps_calcnt;
-	txc->errcnt	   = pps_errcnt;
-	txc->stbcnt	   = pps_stbcnt;
+	txc->jitcnt	   = 0;
+	txc->calcnt	   = 0;
+	txc->errcnt	   = 0;
+	txc->stbcnt	   = 0;
 	write_sequnlock_irq(&xtime_lock);
 	do_gettimeofday(&txc->time);
 	return(result);
#1 lore raw
Quoted 14 lines · Adrian Bunk

The patch below contains some possible cleanups.

I don't claim it's correct, but since all these variables are never changed it doesn't make a difference.

include/linux/timex.h renamed from include/linux/timex.h.old +0 -1
@@ -249,19 +249,11 @@
 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) */

include/linux/timex.h line 264

Quoted 10 lines
include/linux/timex.h renamed from include/linux/timex.h.old +0 -7
 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 */
-

There's an out of tree PPS patch that used those values, but since its out of tree it could just pick up the reversed change. Really, I'm not sure if anyone is using it.

Ulrich? Do you have any comments?

thanks
-john

#2 lore raw
Quoted 30 lines · john stultz
Quoted 14 lines · Adrian Bunk

The patch below contains some possible cleanups.

I don't claim it's correct, but since all these variables are never changed it doesn't make a difference.

include/linux/timex.h renamed from include/linux/timex.h.old +0 -1
@@ -249,19 +249,11 @@
 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) */

include/linux/timex.h line 264

Quoted 10 lines
include/linux/timex.h renamed from include/linux/timex.h.old +0 -7
 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 */
-

There's an out of tree PPS patch that used those values, but since its out of tree it could just pick up the reversed change. Really, I'm not sure if anyone is using it.

Quoted 1 line

Ulrich? Do you have any comments?

AFAIK, adjtimex() [ntp_gettime()] is expected is expected to return those. As long as all those are simply zero, you might optimize that case. However once you want PPS processing you'll have to add them back. However there's little use in:

1) Declaring variables as extern if you don't use them

2) Do external declarations out side an include file [might introduce conflicting external declaration]

Regards,
Ulrich