Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 094aa188 authored by Richard Cochran's avatar Richard Cochran Committed by Thomas Gleixner
Browse files

ntp: Add ADJ_SETOFFSET mode bit



This patch adds a new mode bit into the timex structure. When set, the bit
instructs the kernel to add the given time value to the current time.

Signed-off-by: default avatarRichard Cochran <richard.cochran@omicron.at>
Acked-by: default avatarJohn Stultz <johnstul@us.ibm.com>
LKML-Reference: <20110201134320.688829863@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent c528f7c6
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -73,7 +73,7 @@ struct timex {
	long tolerance;		/* clock frequency tolerance (ppm)
	long tolerance;		/* clock frequency tolerance (ppm)
				 * (read only)
				 * (read only)
				 */
				 */
	struct timeval time;	/* (read only) */
	struct timeval time;	/* (read only, except for ADJ_SETOFFSET) */
	long tick;		/* (modified) usecs between clock ticks */
	long tick;		/* (modified) usecs between clock ticks */


	long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
	long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
@@ -102,6 +102,7 @@ struct timex {
#define ADJ_STATUS		0x0010	/* clock status */
#define ADJ_STATUS		0x0010	/* clock status */
#define ADJ_TIMECONST		0x0020	/* pll time constant */
#define ADJ_TIMECONST		0x0020	/* pll time constant */
#define ADJ_TAI			0x0080	/* set TAI offset */
#define ADJ_TAI			0x0080	/* set TAI offset */
#define ADJ_SETOFFSET		0x0100  /* add 'time' to current time */
#define ADJ_MICRO		0x1000	/* select microsecond resolution */
#define ADJ_MICRO		0x1000	/* select microsecond resolution */
#define ADJ_NANO		0x2000	/* select nanosecond resolution */
#define ADJ_NANO		0x2000	/* select nanosecond resolution */
#define ADJ_TICK		0x4000	/* tick value */
#define ADJ_TICK		0x4000	/* tick value */
+11 −0
Original line number Original line Diff line number Diff line
@@ -648,6 +648,17 @@ int do_adjtimex(struct timex *txc)
			hrtimer_cancel(&leap_timer);
			hrtimer_cancel(&leap_timer);
	}
	}


	if (txc->modes & ADJ_SETOFFSET) {
		struct timespec delta;
		if ((unsigned long)txc->time.tv_usec >= NSEC_PER_SEC)
			return -EINVAL;
		delta.tv_sec  = txc->time.tv_sec;
		delta.tv_nsec = txc->time.tv_usec;
		if (!(txc->modes & ADJ_NANO))
			delta.tv_nsec *= 1000;
		timekeeping_inject_offset(&delta);
	}

	getnstimeofday(&ts);
	getnstimeofday(&ts);


	write_seqlock_irq(&xtime_lock);
	write_seqlock_irq(&xtime_lock);