[PATCH 3/3] ntp: Change ADJ_SETOFFSET implementation to use timekeeping_inject_offset

From: John Stultz
Date: Mon Dec 27 2010 - 18:41:15 EST


Cleans up the ADJ_SETOFFSET implementation to use
timekeeping_inject_offset which greatly simplifies the code.

CC: Richard Cochran <richard.cochran@xxxxxxxxxx>
CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx>
---
kernel/time/ntp.c | 25 ++++++-------------------
1 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index e9e3915..18d7a0f 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -454,7 +454,6 @@ static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts
int do_adjtimex(struct timex *txc)
{
struct timespec ts;
- ktime_t delta, kt;
int result;

/* Validate the data before disabling interrupts */
@@ -484,32 +483,20 @@ int do_adjtimex(struct timex *txc)
}

if (txc->modes & ADJ_SETOFFSET) {
+ struct timespec delta;
/* Validate the delta value. */
if (txc->time.tv_sec && txc->time.tv_usec < 0)
return -EINVAL;

- if (txc->modes & ADJ_NANO) {
- struct timespec tmp;
- tmp.tv_sec = txc->time.tv_sec;
- tmp.tv_nsec = txc->time.tv_usec;
- delta = timespec_to_ktime(tmp);
- } else
- delta = timeval_to_ktime(txc->time);
-
- /* Adding the delta should be an "atomic" operation. */
- local_irq_disable();
+ 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);

- if (txc->modes & ADJ_SETOFFSET) {
- kt = timespec_to_ktime(ts);
- kt = ktime_add(kt, delta);
- ts = ktime_to_timespec(kt);
- do_settimeofday(&ts);
- local_irq_enable();
- }
-
write_seqlock_irq(&xtime_lock);

if (txc->modes & ADJ_ADJTIME) {
--
1.7.3.2.146.gca209

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