Skip to content

Commit

Permalink
timecounter: provide a helper function to shift the time.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Richard Cochran authored and David S. Miller committed Dec 30, 2014
1 parent 74d23cc commit 796c1ef
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/linux/timecounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ static inline u64 cyclecounter_cyc2ns(const struct cyclecounter *cc,
return ret;
}

/**
* 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
Expand Down

0 comments on commit 796c1ef

Please sign in to comment.