Message ID | 1432142376-2077-3-git-send-email-john.stultz@linaro.org |
---|---|
State | Accepted |
Commit | 6374f9124efea5fae9cba263108583c39e22f86b |
Headers | show |
On Wed, May 20, 2015 at 10:53 AM, Harald Geyer <harald@ccbib.org> wrote: > Hi John, > > John Stultz writes: >> From: Harald Geyer <harald@ccbib.org> >> >> 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... Well, I don't think the above covers the same usage, since one is the hrtimer resolution (which we expose to userspace via the posix timers interface) vs the timekeeping/clocksource resolution (which we don't intend to expose to userspace). That said, if you're not sure if this patch is still necessary, I'm happy to drop it, since your iio code was the only potential user so far. :) thanks -john -- 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/
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,