lkml.org 
[lkml]   [2010]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3/3] ntp: Change ADJ_SETOFFSET implementation to use timekeeping_inject_offset
    Date
    Cleans up the ADJ_SETOFFSET implementation to use
    timekeeping_inject_offset which greatly simplifies the code.

    CC: Richard Cochran <richard.cochran@omicron.at>
    CC: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: John Stultz <john.stultz@linaro.org>
    ---
    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


    \
     
     \ /
      Last update: 2010-12-28 00:43    [W:0.031 / U:66.324 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site