diff options
author | Richard Cochran <richardcochran@gmail.com> | 2014-12-21 18:46:57 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-12-30 23:29:25 (GMT) |
commit | 796c1efd6fa0ed696d550b68f4410ab1a1749d01 (patch) | |
tree | 293ff0aa5a0f4b3305672c624b2c50a87a8b181a | |
parent | 74d23cc704d19732e70ef1579a669f7d5f09dd9a (diff) | |
download | linux-796c1efd6fa0ed696d550b68f4410ab1a1749d01.tar.xz |
timecounter: provide a helper function to shift the time.
Some PTP Hardware Clock drivers use a struct timecounter to represent
their clock. To adjust the time by a given offset, these drivers all
perform a two step read/write of their timecounter. However, it is
better and simpler just to adjust the offset in one step. This patch
introduces a little routine to help drivers implement the adjtime
method.
Suggested-by: Janusz Użycki <j.uzycki@elproma.com.pl>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/timecounter.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/timecounter.h b/include/linux/timecounter.h index 146f07a..af3dfa4 100644 --- a/include/linux/timecounter.h +++ b/include/linux/timecounter.h @@ -79,6 +79,15 @@ static inline u64 cyclecounter_cyc2ns(const struct cyclecounter *cc, } /** + * timecounter_adjtime - Shifts the time of the clock. + * @delta: Desired change in nanoseconds. + */ +static inline void timecounter_adjtime(struct timecounter *tc, s64 delta) +{ + tc->nsec += delta; +} + +/** * timecounter_init - initialize a time counter * @tc: Pointer to time counter which is to be initialized/reset * @cc: A cycle counter, ready to be used. |