lkml.org 
[lkml]   [2010]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    SubjectRe: [PATCH 2/3] ntp: add ADJ_SETOFFSET mode bit
    On Tue, Dec 28, 2010 at 8:40 AM, John Stultz <john.stultz@linaro.org> wrote:
    > From: Richard Cochran <richardcochran@gmail.com>
    >
    > 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.

    I came up with this simple solution: "Just use ADJ_OFFSET as usual,
    but don't forget to disable the kernel PLL."

    Here's my (untested) patch.

    ---
    diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
    index c631168..d492887 100644
    --- a/kernel/time/ntp.c
    +++ b/kernel/time/ntp.c
    @@ -119,14 +119,21 @@
    return div_s64(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
    }

    -static void ntp_update_offset(long offset)
    +static void ntp_update_offset(long offset, struct timespec *ts)
    {
    s64 freq_adj;
    s64 offset64;
    long secs;

    - if (!(time_status & STA_PLL))
    + if (!(time_status & STA_PLL)) {
    + offset64 = (s64)offset;
    + if (!(time_status & STA_NANO))
    + offset64 *= NSEC_PER_USEC;
    +
    + set_normalized_timespec(ts, ts->tv_sec, offset64 + ts->tv_nsec);
    +
    return;
    + }

    if (!(time_status & STA_NANO))
    offset *= NSEC_PER_USEC;
    @@ -430,7 +437,7 @@
    time_tai = txc->constant;

    if (txc->modes & ADJ_OFFSET)
    - ntp_update_offset(txc->offset);
    + ntp_update_offset(txc->offset, ts);

    if (txc->modes & ADJ_TICK)
    tick_usec = txc->tick;
    @@ -526,6 +533,9 @@

    write_sequnlock_irq(&xtime_lock);

    + if ((txc->modes & ADJ_OFFSET) && !(time_status & STA_PLL))
    + do_settimeofday(&ts);
    +
    txc->time.tv_sec = ts.tv_sec;
    txc->time.tv_usec = ts.tv_nsec;
    if (!(time_status & STA_NANO))
    --

    \
     
     \ /
      Last update: 2010-12-28 21:51    [W:6.660 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site