Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754630AbbETRxP (ORCPT ); Wed, 20 May 2015 13:53:15 -0400 Received: from h1.radempa.de ([176.9.142.194]:33880 "EHLO mail.cosmopool.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754012AbbETRxN (ORCPT ); Wed, 20 May 2015 13:53:13 -0400 From: Harald Geyer To: John Stultz cc: LKML , Thomas Gleixner , Ingo Molnar Subject: Re: [PATCH 2/7] timekeeping: Provide new API to get the current time resolution In-reply-to: <1432142376-2077-3-git-send-email-john.stultz@linaro.org> References: <1432142376-2077-1-git-send-email-john.stultz@linaro.org> <1432142376-2077-3-git-send-email-john.stultz@linaro.org> Comments: In-reply-to John Stultz message dated "Wed, 20 May 2015 10:19:31 -0700." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3718.1432144385.1@stardust.g4.wien.funkfeuer.at> Date: Wed, 20 May 2015 19:53:05 +0200 Message-Id: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3056 Lines: 88 Hi John, John Stultz writes: > From: Harald Geyer > > This patch series introduces a new function > u32 ktime_get_resolution_ns(void) > which allows to clean up some driver code. thanks for keeping track of this, but is this patch still useful? I was thinking that the variable hrtimer_resolution, that Thomas introduced in https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/include/linux/hrtimer.h?h=timers/wip&id=03eeacdb07e2fdfc4ef311c2593286c92eba609c is meant to provide the same information. I haven't looked into this in detail yet, so I might be wrong, but it is on my todo list for after it appears in the trees I work with... TIA, Harald > In particular the IIO subsystem has a function to provide timestamps for > events but no means to get their resolution. So currently the dht11 driver > tries to guess the resolution in a rather messy and convoluted way. We > can do much better with the new code. > > This API is not designed to be exposed to user space. > > This has been tested on i386, sunxi and mxs. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Signed-off-by: Harald Geyer > [jstultz: Tweaked to make it build after upstream changes] > Signed-off-by: John Stultz > --- > include/linux/timekeeping.h | 1 + > kernel/time/timekeeping.c | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h > index 99176af..9af5c12 100644 > --- a/include/linux/timekeeping.h > +++ b/include/linux/timekeeping.h > @@ -163,6 +163,7 @@ extern ktime_t ktime_get(void); > extern ktime_t ktime_get_with_offset(enum tk_offsets offs); > extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs); > extern ktime_t ktime_get_raw(void); > +extern u32 ktime_get_resolution_ns(void); > > /** > * ktime_get_real - get the real (wall-) time in ktime_t format > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c > index 3365e32..85d3763 100644 > --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -702,6 +702,23 @@ ktime_t ktime_get(void) > } > EXPORT_SYMBOL_GPL(ktime_get); > > +u32 ktime_get_resolution_ns(void) > +{ > + struct timekeeper *tk = &tk_core.timekeeper; > + unsigned int seq; > + u32 nsecs; > + > + WARN_ON(timekeeping_suspended); > + > + do { > + seq = read_seqcount_begin(&tk_core.seq); > + nsecs = tk->tkr_mono.mult >> tk->tkr_mono.shift; > + } while (read_seqcount_retry(&tk_core.seq, seq)); > + > + return nsecs; > +} > +EXPORT_SYMBOL_GPL(ktime_get_resolution_ns); > + > static ktime_t *offsets[TK_OFFS_MAX] = { > [TK_OFFS_REAL] = &tk_core.timekeeper.offs_real, > [TK_OFFS_BOOT] = &tk_core.timekeeper.offs_boot, > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/