At Fri, 15 Jun 2012 05:02:38 -0500, Pierre-Louis Bossart wrote:
+struct azx_timecounter {
- cycle_t cycle_last;
- cycle_t mask;
- cycle_t elapsed_cycles;
- u64 initial_time_nsec;
- u32 mult;
- u32 shift;
+};
Any reason not using the normal struct timecounter stuff? Most of the open codes can be replaced gracefully with functions / macros there, I guess.
Yes there is a reason. The conversion from wall clock cycles to ns is a fractional operation (125/3 ratio from 24 MHz to 1 GHz). If you do this conversion to ns every time, you will accumulate rounding errors. That doesn't seem like a very good design if the precision depends on the duration of the track...
Hm, OK. It's a shortcoming in the generic timecounter code, IMO. It might make more sense to fix there.
BTW, the calculation mult can be simplified with clocksource_khz2multi().
On top of this, I couldn't find a way to pass the 'chip' argument in the cyclecounter .read() operation to map it to azx_read.
You can use container_of().
Takashi