From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kuwahara,T." <6vvetjsrt26xsrzlh1z0zn4d2grdah-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Subject: Re: [PATCH V8 02/13] ntp: add ADJ_SETOFFSET mode bit Date: Sun, 2 Jan 2011 05:38:19 +0900 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Richard Cochran Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Alan Cox , Arnd Bergmann , Christoph Lameter , David Miller , John Stultz , Krzysztof Halasa , Peter Zijlstra , Rodolfo Giometti , Thomas Gleixner List-Id: linux-api@vger.kernel.org On Sat, Jan 1, 2011 at 4:12 AM, Richard Cochran wrote: > +#define ADJ_SETOFFSET =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x0040 =C2=A0= /* add 'time' to current time */ As you know, it conflicts with MOD_PPSMAX. And also, it is logically the same as ADJ_OFFSET, unless the kernel PLL is enabled explicitly. So here's my simple solution: --- 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 =3D offset; + if (!(time_status & STA_NANO)) + offset64 *=3D NSEC_PER_USEC; + + set_normalized_timespec(ts, ts->tv_sec, offset64 + ts->tv_nsec); + return; + } if (!(time_status & STA_NANO)) offset *=3D NSEC_PER_USEC; @@ -430,7 +437,7 @@ time_tai =3D 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 =3D 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 =3D ts.tv_sec; txc->time.tv_usec =3D ts.tv_nsec; if (!(time_status & STA_NANO)) --