Messages in this thread | | | Date | Tue, 28 Feb 2012 09:06:47 +0100 | From | Ingo Molnar <> | Subject | Re: [PATCH 1/7] time: Condense timekeeper.xtime into xtime_sec |
| |
* John Stultz <john.stultz@linaro.org> wrote:
> --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -39,8 +39,11 @@ struct timekeeper { > /* Raw nano seconds accumulated per NTP interval. */ > u32 raw_interval; > > - /* Clock shifted nano seconds remainder not stored in xtime.tv_nsec. */ > + /* Current CLOCK_REALTIME time in seconds */ > + u64 xtime_sec; > + /* Clock shifted nano seconds */ > u64 xtime_nsec; > + > /* Difference between accumulated time and NTP time in ntp > * shifted nano seconds. */ > s64 ntp_error; > @@ -48,8 +51,6 @@ struct timekeeper { > * ntp shifted nano seconds. */ > int ntp_error_shift; > > - /* The current time */ > - struct timespec xtime;
Please use consistent vertical spacing for this structure.
> +static struct timespec timekeeper_xtime(struct timekeeper *tk) > +{ > + struct timespec ts; > + > + ts.tv_sec = tk->xtime_sec; > + ts.tv_nsec = (long)(tk->xtime_nsec >> tk->shift); > + return ts; > +}
btw., is tk->shift intentionally a signed int? If not then it would be better to make it u32, like tk->mult, to make sure the compiler never does complex signed arithmetics - and to clean up 'struct timekeeper'.
> + > +static void timekeeper_set_xtime(struct timekeeper *tk, > + const struct timespec *ts)
Pointless (because ugly) line break.
> +{ > + tk->xtime_sec = ts->tv_sec; > + tk->xtime_nsec = ts->tv_nsec << tk->shift; > +} > + > + > +static void timekeeper_xtime_add(struct timekeeper *tk, > + const struct timespec *ts)
Pointless (because ugly) line break.
Thanks,
Ingo
| |