aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/timex.h3
-rw-r--r--kernel/time/ntp.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/timex.h b/include/linux/timex.h
index d23999f9499d..aa60fe7b6ed6 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -73,7 +73,7 @@ struct timex {
73 long tolerance; /* clock frequency tolerance (ppm) 73 long tolerance; /* clock frequency tolerance (ppm)
74 * (read only) 74 * (read only)
75 */ 75 */
76 struct timeval time; /* (read only) */ 76 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */
77 long tick; /* (modified) usecs between clock ticks */ 77 long tick; /* (modified) usecs between clock ticks */
78 78
79 long ppsfreq; /* pps frequency (scaled ppm) (ro) */ 79 long ppsfreq; /* pps frequency (scaled ppm) (ro) */
@@ -102,6 +102,7 @@ struct timex {
102#define ADJ_STATUS 0x0010 /* clock status */ 102#define ADJ_STATUS 0x0010 /* clock status */
103#define ADJ_TIMECONST 0x0020 /* pll time constant */ 103#define ADJ_TIMECONST 0x0020 /* pll time constant */
104#define ADJ_TAI 0x0080 /* set TAI offset */ 104#define ADJ_TAI 0x0080 /* set TAI offset */
105#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
105#define ADJ_MICRO 0x1000 /* select microsecond resolution */ 106#define ADJ_MICRO 0x1000 /* select microsecond resolution */
106#define ADJ_NANO 0x2000 /* select nanosecond resolution */ 107#define ADJ_NANO 0x2000 /* select nanosecond resolution */
107#define ADJ_TICK 0x4000 /* tick value */ 108#define ADJ_TICK 0x4000 /* tick value */
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)
648 hrtimer_cancel(&leap_timer); 648 hrtimer_cancel(&leap_timer);
649 } 649 }
650 650
651 if (txc->modes & ADJ_SETOFFSET) {
652 struct timespec delta;
653 if ((unsigned long)txc->time.tv_usec >= NSEC_PER_SEC)
654 return -EINVAL;
655 delta.tv_sec = txc->time.tv_sec;
656 delta.tv_nsec = txc->time.tv_usec;
657 if (!(txc->modes & ADJ_NANO))
658 delta.tv_nsec *= 1000;
659 timekeeping_inject_offset(&delta);
660 }
661
651 getnstimeofday(&ts); 662 getnstimeofday(&ts);
652 663
653 write_seqlock_irq(&xtime_lock); 664 write_seqlock_irq(&xtime_lock);