john stultz b5776c4a6d Fix rounding in clocks_calc_mult_shift()
Russell King reports:
| On the ARM dev boards, we have a 32-bit counter running at 24MHz.  Calling
| clocks_calc_mult_shift(&mult, &shift, 24MHz, NSEC_PER_SEC, 60) gives
| us a multiplier of 2796202666 and a shift of 26.
|
| Over a large counter delta, this produces an error - lets take a count
| from 362976315 to 4280663372:
|
| (4280663372-362976315) * 2796202666 / 2^26 - (4280663372-362976315) * (1000/24)
|  => -38.91872422891230269990
|
| Can we do better?
|
| (4280663372-362976315) * 2796202667 / 2^26 - (4280663372-362976315) * (1000/24)
| 19.45936211449532822051
|
| which is about twice as good as the 2796202666 multiplier.
|
| Looking at the equivalent divisions obtained, 2796202666 / 2^26 gives
| 41.66666665673255920410ns per tick, whereas 2796202667 / 2^26 gives
| 41.66666667163372039794ns.  The actual value wanted is 1000/24 =
| 41.66666666666666666666ns.

Fix this by ensuring we round to nearest when calculating the
multiplier.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Will Deacon <will.deacon@arm.com>
Tested-by: Mikael Pettersson <mikpe@it.uu.se>
Tested-by: Eric Miao <eric.y.miao@gmail.com>
Tested-by: Olof Johansson <olof@lixom.net>
Tested-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-12-22 22:44:43 +00:00
..
2010-08-09 16:48:42 -04:00
2010-07-14 11:29:46 +02:00
2010-10-30 01:42:19 -04:00
2010-10-30 01:42:19 -04:00
2010-10-30 08:45:43 -04:00
2010-10-29 04:17:06 -04:00
2010-10-29 04:17:06 -04:00
2009-09-18 09:48:52 -07:00
2010-10-01 10:50:58 -07:00
2010-06-29 10:07:09 +02:00
2010-10-18 18:44:26 +02:00
2010-08-11 23:04:20 +09:30
2010-08-19 17:18:02 -07:00
2010-08-20 08:55:00 -07:00
2010-10-27 17:28:36 +01:00
2010-10-27 18:03:17 -07:00
2010-07-27 12:40:54 +02:00
2009-09-23 18:13:10 -07:00
2009-06-18 13:03:55 -07:00
2010-10-26 16:52:14 -07:00