summaryrefslogtreecommitdiff
path: root/kernel/time
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2011-02-01 16:52:20 +0300
committerThomas Gleixner <tglx@linutronix.de>2011-02-02 17:28:18 +0300
commit094aa1881fdc1b8889b442eb3511b31f3ec2b762 (patch)
tree2eec808286e2f57eff45178741ba3ea048de7c37 /kernel/time
parentc528f7c6c208f1fae6b4025957173dec045e5f21 (diff)
downloadlinux-094aa1881fdc1b8889b442eb3511b31f3ec2b762.tar.xz
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: Richard Cochran <richard.cochran@omicron.at> Acked-by: John Stultz <johnstul@us.ibm.com> LKML-Reference: <20110201134320.688829863@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/ntp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index ed8cfdf16983..5ac593267a26 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -648,6 +648,17 @@ int do_adjtimex(struct timex *txc)
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);
write_seqlock_irq(&xtime_lock);